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

Path *bug* using wrong node binary. #5789

Open
GlassGhost opened this issue May 5, 2018 · 10 comments
Open

Path *bug* using wrong node binary. #5789

GlassGhost opened this issue May 5, 2018 · 10 comments

Comments

@GlassGhost
Copy link

GlassGhost commented May 5, 2018

What is the current behavior?
Install command fails; won't run without sudo access, using wrong path to get node binary.

owner@Z50-75:~/yarn-sandbox/simple-samples/hash$ ~/yarn-sandbox/node/node ~/yarn-sandbox/yarn-1.6.0.js --cache-folder ~/yarn-sandbox/yarncache install
yarn install v1.6.0
info No lockfile found.
[1/4] Resolving packages...
warning electron > electron-download > nugget > progress-stream > through2 > xtend > object-keys@0.4.0: 
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[1/1] ⠂ electron
[-/1] ⠂ waiting...
[-/1] ⠂ waiting...
[-/1] ⠂ waiting...
error /home/owner/yarn-sandbox/simple-samples/hash/node_modules/electron: Command failed.
Exit code: 127
Command: node install.js
Arguments: 
Directory: /home/owner/yarn-sandbox/simple-samples/hash/node_modules/electron




owner@Z50-75:~/yarn-sandbox/simple-samples/hash$ ~/yarn-sandbox/node/node ~/yarn-sandbox/yarn-1.6.0.js start
yarn run v1.6.0
$ electron app.js
/usr/bin/env: ‘node’: No such file or directory
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
owner@Z50-75:~/yarn-sandbox/simple-samples/hash$ 

If the current behavior is a bug, please provide the steps to reproduce.
My friend didn't have node installed on his system so I sent him the commands to compile it, on my system I believe it's using the wrong version of node to install it wouldn't work on his system(vanilla ubuntu 16.04) without first running the commented out link command.

#Sandbox for https://github.com/electron/electron
mkdir ~/yarn-sandbox
cd ~/yarn-sandbox
wget https://github.com/yarnpkg/yarn/releases/download/v1.6.0/yarn-1.6.0.js
git clone https://github.com/electron/simple-samples
git clone -b 'v8.11.1' --single-branch --depth 1 https://github.com/nodejs/node
cd ~/yarn-sandbox/node
./configure
make -j4

#this shouldn't be necessary
#sudo ln -s '/home/owner/yarn-sandbox/node/out/Release/node' /usr/bin/node

cd ~/yarn-sandbox/simple-samples/hash
~/yarn-sandbox/node/node ~/yarn-sandbox/yarn-1.6.0.js --cache-folder ~/yarn-sandbox/yarncache install
~/yarn-sandbox/node/node ~/yarn-sandbox/yarn-1.6.0.js start

What is the expected behavior?
Should not need sudo access to /usr/bin/node
screenshot

Please mention your node.js, yarn and operating system version.

@ghost ghost assigned BYK May 5, 2018
@ghost ghost added the triaged label May 5, 2018
@GlassGhost
Copy link
Author

I believe this should be a serious issue, ESPECIALLY for people managing multiple projects running different versions of node.

@rally25rs
Copy link
Contributor

I'm pretty sure it's going to use whatever node is on your PATH. You probably want to add the --scripts-prepend-node-path flag, which prepends whatever node you used to execute yarn to the path. Unfortunately that flag was broken, fixed by #5776 but not yet released.

According to the npm run-script docs it looks like npm will automatically do what that flag does if node isn't found in the PATH, but yarn may not have that fallback implemented.

@GlassGhost
Copy link
Author

Seems to me like ‘--scripts-prepend-node-path‘ should be enabled by default, why would a user manually use a specific version of node only for it to search through your path for whatever version it finds first????

@rally25rs
Copy link
Contributor

Marking this issue as a feature-request to change the behavior of the PATH building to assume --scripts-prepend-node-path by default, to better match what npm does.

If --scripts-prepend-node-path=auto is passed (which has been the default in npm v3), this is only performed when that node executable is not found in the PATH.

so if the node executable that was used to run yarn is not found in the current path, we should treat it as if this flag is enabled and add the path.

@GlassGhost
Copy link
Author

GlassGhost commented May 10, 2018

I thought it was a bug; @rally25rs I agree, this is a feature request. I hope this goes through promptly so we can close this request.

I'm considering making a gui for yarn with electron, that enables users to select versions of dependencies based upon github release tags, maybe even some fork awareness.

@BYK BYK assigned arcanis and unassigned BYK May 11, 2018
@BYK
Copy link
Member

BYK commented May 11, 2018

I think @arcanis did something like this lately or war talking about it.

@arcanis
Copy link
Member

arcanis commented May 11, 2018

Yep, I have a WIP that adds both yarn and node to the PATH, so that users are always guaranteed to use the exact same version of Node that the one Yarn is currently using, and the exact same version of Yarn that the one running the install. I still have a few details to figure out, but it's in progress.

@arcanis
Copy link
Member

arcanis commented May 11, 2018

In the meantime, the recommended workaround is to use $NODE and $npm_execpath which are guaranteed to point to the right binaries (but that nobody use because it would be too easy :).

briandk added a commit to briandk/transcriptase that referenced this issue Jun 16, 2018
This seems to be a bug in yarn; yarn run ___ doesn't find the binary because something in yarn isn't setting $PATH properly.

refs yarnpkg/yarn#5789
@GlassGhost
Copy link
Author

GlassGhost commented Sep 15, 2018

@arcanis

Yep, I have a WIP that adds both yarn and node to the PATH, so that users are always guaranteed to use the exact same version of Node that the one Yarn is currently using, and the exact same version of Yarn that the one running the install. I still have a few details to figure out, but it's in progress.

Do you have a branch url for the WIP?

@arcanis
Copy link
Member

arcanis commented Sep 15, 2018

It's part of the Plug'n'Play PR: #6382 - I'll wait a few days before merging it, but it should be released with the 1.10

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

No branches or pull requests

4 participants