Skip to content

Fresh install of n can't be used #782

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

Closed
Lovasz-Akos opened this issue Sep 7, 2023 · 8 comments
Closed

Fresh install of n can't be used #782

Lovasz-Akos opened this issue Sep 7, 2023 · 8 comments

Comments

@Lovasz-Akos
Copy link

Bug Report

Summary

Just installed n with npm install -g n and using n latest breaks

Steps to Reproduce

npm install -g n
n latest

Expected Behaviour

Installs latest nodejs

Actual Behaviour

$ n latest
/bin/n: line 108: syntax error: unexpected "("

Configuration Details

$ n --version
also returns 
/bin/n: line 108: syntax error: unexpected "("

$ command -v node
/bin/node

$ node -p process.platform
linux
@Lovasz-Akos
Copy link
Author

fixed by using the POSIX compliant version on the POSIX branch

@shadowspawn
Copy link
Collaborator

What version of Bash are you using in the failing environment?

There is some interesting syntax on that line, so maybe a really old or really new version of Bash is complaining:

n/bin/n

Line 108 in 02a8fe0

CURL_OPTIONS=( "--location" "--fail" "--show-error" )

@Lovasz-Akos
Copy link
Author

I'm using sh, not bash, that might be the issue here

@shadowspawn
Copy link
Collaborator

The n script starts with a shebang interpreter directive to use bash:

n/bin/n

Line 1 in 02a8fe0

#!/usr/bin/env bash

So in theory you can use sh (or zsh et al) as your shell, but the n script is interpreted using bash.

What version of Bash are you using in the failing environment?

Assuming you have a bash available, what I meant was what version is it? For example, I see:

% bash --version 
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin21)
Copyright (C) 2007 Free Software Foundation, Inc.

@Lovasz-Akos
Copy link
Author

Sadly no bash, it's a super barebones buildroot system i'm testing, I don't even have apt or curl which makes changing node versions...difficult. n comes to save the day, since I do have npm, but that syntax breaks on sh. #751 's changes fix this so I'm looking forward to it's merge or completion :)

@shadowspawn
Copy link
Collaborator

Thanks for the info. A vote for the posix compatible version. :-)

@Lovasz-Akos
Copy link
Author

(although it acted a little strange on my try, n's tui only saw the version it installed and not the one already present on the system, and it couldn't switch my active install)

@shadowspawn
Copy link
Collaborator

and it couldn't switch my active install

That sounds like an issue with node installed twice, likely once into /usr/bin (by some other process) and into /usr/local/bin by n. The version which is found depends on the order of directories in the PATH environment variable.

If you run n doctor it will check for this situation.

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