Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FR] musl/AlpineLinux support #46

Open
ITwrx opened this issue Oct 6, 2024 · 8 comments
Open

[FR] musl/AlpineLinux support #46

ITwrx opened this issue Oct 6, 2024 · 8 comments

Comments

@ITwrx
Copy link

ITwrx commented Oct 6, 2024

Using the curl/wget install instructions fails on musl/alpine linux. I figured it would, but i wanted to see what happened.

~/Downloads $ wget -qO - https://nim-lang.org/choosenim/init.sh | sh
choosenim-init: Downloading choosenim-0.8.9_linux_amd64
sh: /tmp/choosenim-0.8.9_linux_amd64: not found

/tmp/choosenim-0.8.9_linux_amd64 exists

Tried to build choosenim from source, but it can't build nimble from source, so that fails too. The nim package in alpine is also out of date, so i'm stuck on 2.0.4 for any alpine/musl targets, which is a production-grade problem for me.

Thanks

@SpotlightKid
Copy link

What error(s) do you get when you try to build choosenim from source?

@ITwrx
Copy link
Author

ITwrx commented Oct 6, 2024

~/Downloads/choosenim-0.8.9 $ nimble install
  Verifying dependencies for [email protected]
 Installing https://github.com/nim-lang/sat@any version
Downloading https://github.com/nim-lang/sat using git
   Warning: The package has no tagged releases, downloading HEAD instead.
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  sat installed successfully.
 Installing nimble@#ed0b6ee
Downloading https://github.com/nim-lang/nimble using git
  Verifying dependencies for [email protected]
     Info:  Dependency on sat@any version already satisfied
  Verifying dependencies for [email protected]
 Installing checksums@any version
Downloading https://github.com/nim-lang/checksums using git
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  checksums installed successfully.
 Installing [email protected]
   Building nimble/nimble using c backend
/tmp/nimble_4649/githubcom_nimlangnimble_#ed0b6ee/src/nimblepkg/tools.nim(11, 23) Error: cannot open file: /usr/lib/nim/compiler/nimblecmd
       Tip: 30 messages have been suppressed, use --verbose to show them.
nimble.nim(229)          buildFromDir

    Error:  Build failed for the package: nimble

@SpotlightKid
Copy link

Building nimble/nimble using c backend
/tmp/nimble_4649/githubcom_nimlangnimble_#ed0b6ee/src/nimblepkg/tools.nim(11, 23) Error: cannot open file: /usr/lib/nim/compiler/nimblecmd
       Tip: 30 messages have been suppressed, use --verbose to show them.
nimble.nim(229)          buildFromDir

This is a problem with your alpine Nim installation. It is missing the compiler package. This can happen, for example, if you use the install.sh script from the Nim source distribution to install Nim to /usr, instead of running Nim from the build directory or installing it to another prefix. This unfortunately also affects many Linux distribution packages for Nim.

You can use the nimlang/nim:alpine docker image (not official) to build choosenim. It has nim (currently 2.0.8) installed to the /nim prefix:

$ wget https://github.com/nim-lang/choosenim/archive/refs/tags/v0.8.9.tar.gz
$ docker run --rm -v `pwd`:/usr/src/app -w /usr/src/app -it --init nimlang/nim:alpine /bin/sh
# tar -xzf v0.8.9.tar.gz
# cd choosenim-0.8.9
# nimble install
  Verifying dependencies for [email protected]
Downloading Official package list
    Success Package list downloaded.
 Installing https://github.com/nim-lang/sat@any version
Downloading https://github.com/nim-lang/sat using git
   Warning: The package has no tagged releases, downloading HEAD instead.
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  sat installed successfully.
 Installing nimble@#ed0b6ee
Downloading https://github.com/nim-lang/nimble using git
   Warning: Package 'nimble' has an incorrect structure. It should contain a single directory hierarchy for source files, named 'nimble', but file 'options.nim' is in a directory named 'nimblepkg' instead. This will be an error in the future.
      Hint: If 'nimblepkg' contains source files for building 'nimble', rename it to 'nimble'. Otherwise, prevent its installation by adding `skipDirs = @["nimblepkg"]` to the .nimble file.
  Verifying dependencies for [email protected]
     Info:  Dependency on sat@any version already satisfied
  Verifying dependencies for [email protected]
 Installing checksums@any version
Downloading https://github.com/nim-lang/checksums using git
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  checksums installed successfully.
 Installing [email protected]
   Building nimble/nimble using c backend
  Success:  nimble installed successfully.
 Installing libcurl@>= 1.0.0
Downloading https://github.com/Araq/libcurl using git
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  libcurl installed successfully.
 Installing osinfo@any version
Downloading https://github.com/nim-lang/osinfo.git using git
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  osinfo installed successfully.
 Installing zippy@>= 0.7.2
Downloading https://github.com/guzba/zippy using git
  Verifying dependencies for [email protected]
 Installing [email protected]
  Success:  zippy installed successfully.
 Installing [email protected]
   Building choosenim/choosenim using c backend
/root/.nimble/pkgs2/nimble-0.14.2-d7a5be15af06f993ee52303b8797d56a4caa7c3b/nimblepkg/options.nim(270, 16) Warning: Couldn't determine GIT hash: fatal: not a git repository (or any of the parent directories): .git [User]
/usr/src/app/choosenim-0.8.9/src/choosenimpkg/download.nim(73, 26) Warning: See corresponding Defect; AssertionError is deprecated [Deprecated]
/usr/src/app/choosenim-0.8.9/src/choosenimpkg/switcher.nim(9, 10) Warning: imported and not used: 'utils' [UnusedImport]
  Success:  choosenim installed successfully.
# choosenim stable
Downloading Nim 2.2.0 from nim-lang.org
[##################################################] 100.0% 0kb/s
 Extracting nim-2.2.0-linux_x64.tar.xz
 Extracting nim-2.2.0-linux_x64.tar
   Building Nim 2.2.0
  Compiler: Already built
  Installed component 'nim'
    Removed symlink pointing to ../pkgs2/nimble-0.14.2-d7a5be15af06f993ee52303b8797d56a4caa7c3b/nimble
  Installed component 'nimble'
  Installed component 'nimgrep'
  Installed component 'nimpretty'
  Installed component 'nimsuggest'
  Installed component 'testament'
  Installed component 'nim-gdb'
   Switched to Nim 2.2.0
# nim -v
Nim Compiler Version 2.2.0 [Linux: amd64]
Compiled at 2024-10-02
Copyright (c) 2006-2024 by Andreas Rumpf

git hash: 78983f1876726a49c69d65629ab433ea1310ece1
active boot switches: -d:release

@ITwrx
Copy link
Author

ITwrx commented Oct 19, 2024

This is a problem with your alpine Nim installation. It is missing the compiler package. This can happen, for example, if you use the install.sh script from the Nim source distribution to install Nim to /usr, instead of running Nim from the build directory or installing it to another prefix. This unfortunately also affects many Linux distribution packages for Nim.

I don't understand. What is wrong with Nim distro packages? I'm looking to update the Alpine Nim package. Is there something i should be correcting?

You can use the nimlang/nim:alpine docker image (not official) to build choosenim. It has nim (currently 2.0.8) installed to the /nim prefix:

Thanks for the workaround, but it didn't work for me. Don't remember why. I don't use Docker, so maybe i was doing something wrong. It's OK, but i'm curious why the docker image would install to /nim and/or why that would be a good thing.

@ITwrx
Copy link
Author

ITwrx commented Oct 19, 2024

well, i forked the nim package in the alpine gitlab and updated it and installed nim 2.2.0 successfully, but the nimble package failed to build. When investigating that, i see that araq says nimble should not be in a separate package, but that one could install nimble with koch nimble --latest. but koch was not installed by the/my alpine package, it seems. I think i'm done with this for today...

@SpotlightKid
Copy link

koch is a tool that is part of the Nim source distribution and not meant to be installed. It is used to build the nim tools (nimble, nimsuggest, etc.) after the nim compiler itself has been build. Then these tools will be installed by the install script alongside the nim executable. So they should be part of a binary nim distribution package. But not koch. And nimble should not be installed from a nimble package.

@ITwrx
Copy link
Author

ITwrx commented Oct 19, 2024

ok, so my Nim alpine package should have used koch temporarily to build nimble when it was doing the other stuff.

thanks

@SpotlightKid
Copy link

correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants