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

Improve dependency management #24549

Closed
peppergrayxyz opened this issue Dec 19, 2024 · 1 comment
Closed

Improve dependency management #24549

peppergrayxyz opened this issue Dec 19, 2024 · 1 comment

Comments

@peppergrayxyz
Copy link

Description

Currently, gcc, git and ~/.chossenim/current are needed to use nim:

It should just work with CC provided

Nim Version

  • choosenim v0.8.10
  • Nim 2.2.0

Current Output

$ CC=zig choosenim --choosenimDir:$nimpath/my-choosenim --nimbleDir:$nimpath/my-nimbledir stable
     Error: No C compiler found. Nim compiler requires a C compiler.
        ... Install gcc using your favourite package manager.
$ export PATH=$nimpath/my-nimbledir/bin:$PATH
$ CC=zig nimble rel
       Tip: 1 messages have been suppressed, use --verbose to show them.
tools.nim(52)            doCmdEx

    Error:  'git' not in PATH.

Expected Output

$ choosenim --choosenimDir:$nimpath/my-choosenim --nimbleDir:$nimpath/my-nimbledir stable
$ export PATH=$nimpath/my-nimbledir/bin:$PATH
$ nimble rel
    Success

Known Workarounds

# config
cc=zig
nim_path="/home/user/dev/choosenim"
choosenim_path="my-choosenim"
nimble_path="my-nimble"
release="0.8.4"

### get & unpack
mkdir -p "$nim_path"
pushd "$nim_path"
wget -O "choosenim" https://github.com/nim-lang/choosenim/releases/download/v${release}/choosenim-${release}_linux_amd64
chmod +x "choosenim"

### install

# nim-lang#62 - gcc is hard coded
nim_patch_path="`pwd`"
printf "#\!/bin/sh\n\$CC\n" > "$nim_patch_path/gcc"
chmod +x "$nim_patch_path/gcc"

# run choosenim with custom paths
PATH="$nim_patch_path:$PATH" CC="$cc" ./choosenim --choosenimDir:"$choosenim_path" --nimbleDir:"$nimble_path" --firstInstall stable

# nim-lang#1319 - setup fake git
nimble_git="$nimble_path/bin/git"
printf "#\!/bin/sh\nif command -v /usr/bin/git 2>&1 >/dev/null; then /usr/bin/git "\$@"; else exit 0; fi\n" > "$nimble_git"
chmod +x "$nimble_git"

# choosenim#61
mkdir -p ".choosenim"
ln -s "../$choosenim_path/current" ".choosenim/current"

popd

### run

# setup env
export PATH="$nim_path/$nimble_path/bin:$PATH"

# run nimble (with fake home dir Nim#24281)
HOME=$nim_path nimble rel

Additional Information

No response

@Araq
Copy link
Member

Araq commented Dec 20, 2024

Plenty of people, myself included use Nim without any choosenim. You can even use Nim without Nimble. The C compiler is hardcoded because we expoit its individual non-standard features and Zig is just a clang as far as Nim is concerned, easily configurable.

@Araq Araq closed this as completed Dec 20, 2024
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