-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Globally installed binaries do not work in PowerShell after 1.13.0 #6902
Comments
Same issue https://ci.appveyor.com/project/vladimiry/email-securely-app/build/job/p9cy9yoosgfylw50 right?
cli.js:45726:
|
No, that looks like a syntax error in the actual JS file. This is causing a syntax error is coming from PowerShell because it's finding a PS1 file that actually contains a Unix Bash script |
Fixes yarnpkg#6902. Leave in yarn.cmd in case anyone is still using cmd on Windows in 2018.
I am having the exact same issue and can confirm downgrading to 1.12.3 after clearing the global bin does fix the issue. Here is a gist for the files created by Yarn 1.12.3 for As @briman0094 stated, the xxx.ps1 file contains the Unix bash script. |
bump |
This is so annoying. Bash syntax in |
I bumped into the similar problem. 😕
tatsu@TATSU-NB-3RD:/mnt/c/Users/tatsu/Documents$ diff -up /mnt/c/Users/tatsu/scoop/apps/yarn/current/bin/yo{,.ps1}
--- /mnt/c/Users/tatsu/scoop/apps/yarn/current/bin/yo 2019-01-17 00:58:48.299169900 +0900
+++ /mnt/c/Users/tatsu/scoop/apps/yarn/current/bin/yo.ps1 2019-01-17 00:58:48.485789500 +0900
@@ -5,11 +5,11 @@ case `uname` in
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
esac
-if [ -x "$basedir//bin/sh" ]; then
- "$basedir//bin/sh" "$basedir/../../../../../AppData/Local/Yarn/Data/global/node_modules/.bin/yo" "$@"
+if [ -x "$basedir/pwsh" ]; then
+ "$basedir/pwsh" "$basedir/../../../../../AppData/Local/Yarn/Data/global/node_modules/.bin/yo.ps1" "$@"
ret=$?
else
- /bin/sh "$basedir/../../../../../AppData/Local/Yarn/Data/global/node_modules/.bin/yo" "$@"
+ pwsh "$basedir/../../../../../AppData/Local/Yarn/Data/global/node_modules/.bin/yo.ps1" "$@"
ret=$?
fi
exit $ret
tatsu@TATSU-NB-3RD:/mnt/c/Users/tatsu/Documents$ diff -up /mnt/c/Users/tatsu/scoop/apps/yarn/current/bin/yo.{cmd,ps1}.ps1
--- /mnt/c/Users/tatsu/scoop/apps/yarn/current/bin/yo.cmd.ps1 2019-01-17 00:58:48.447668900 +0900
+++ /mnt/c/Users/tatsu/scoop/apps/yarn/current/bin/yo.ps1.ps1 2019-01-17 00:58:48.485165400 +0900
@@ -7,5 +7,12 @@ if ($PSVersionTable.PSVersion -lt "6.0"
# are installed in the same directory
$exe=".exe"
}
-& "$basedir/../../../../../AppData/Local/Yarn/Data/global/node_modules/.bin/yo.cmd" $args
-exit $LASTEXITCODE
+$ret=0
+if (Test-Path "$basedir/pwsh$exe") {
+ & "$basedir/pwsh$exe" "$basedir/../../../../../AppData/Local/Yarn/Data/global/node_modules/.bin/yo.ps1" $args
+ $ret=$LASTEXITCODE
+} else {
+ & "pwsh$exe" "$basedir/../../../../../AppData/Local/Yarn/Data/global/node_modules/.bin/yo.ps1" $args
+ $ret=$LASTEXITCODE
+}
+exit $ret |
How to avoid this problem provisionally:
I wonder why ONLY global packages cause this probrem. There is no problem in packages in every |
I found the mechanism of this bug.
yarn/src/cli/commands/global.js Lines 169 to 171 in 1af4c5f
|
Same problem. Rolled back to 1.12.3, :( |
+1 |
Fun fact: after fixing the duplicate-extension issue, I determined that the |
@briman0094 It's not a problem that |
As this issue is likely to be closen by the makeshift, it's necessary to create a new issue to spread of the root of this problem. |
Yarn was creating shims of shims before the 1.13.0 update. The difference is that it took care of the duplicates after the fact. I agree that the root cause needs to be addressed (which would most likely allow the new PowerShell shims to actually work correctly), but every PowerShell user who updates to 1.13.0 is left unable to use any globally-installed packages whatsoever. It would make sense to regress the change that broke the shims as a minor update until a proper fix can be applied, as opposed to making all PowerShell users suffer until then. |
All right, this issue must be fixed ASAP and even a hotfix must be merged. I can wait for the root of this problem solved. |
Why is yarn using .ps1 files to begin with? Aren't the generated .cmd files enough? |
Yarn isn't generating the .PS1 files; |
It seems this update (on Yarn) was not done properly, so why this was not reverted yet? At least, until someone takes the time required to do it right and test it? |
mark.tks |
This is why I don't like yarn - they don't care about windows at all. Here is another example. |
@torifat, @arcanis - The fix for this issue (#6954) seems to have been waiting to be merged for the last month and at least one major release. Is there anything that can be done to expedite this. Is it worth while creating an alternate pull request if there is some problem blocking this one? I might add that not only does this issue make yarn global unusable on Windows, accidentally running it also hoses npm -g installations which I had hoped would provide a workaround. |
I actually submitted two possible fixes in hopes that one might be accepted sooner than the other but neither has been reviewed by a maintainer...it's certainly surprising that nobody has looked at them yet. This causes major widespread issues on Windows. |
So, this problem still not solved in Release Candidate v1.15.0? Not solved after 2 candidate version released? It's time to say goodbye (before this issue solved or forever). :) |
Due to a fetal issue on Windows' Yarn yarnpkg/yarn#6902, Change packages management to NPM :) Local-installed Taro cli instead of global-installed.
Let's clear up a misconception.
First, we don't have enough day-to-day core contributors - I've been the only one actively merging PRs this past year. If there's anything I should be spending my time on, it would be finding new contributors willing to help managing this repository. Second, I'm working on a major release that overhaul most of the components affected in those issues. My priorities currently are long-term issues more than implementation ones - since the implementation will change anyway. Third, I'm rewriting our documentation. Think of it as writing a book - it's really not something you have just by wishing it with all your heart - you need to spend time on it. Fourth, I have an actual job I'm being paid to do, and maintaining Yarn is but a part of it. I've literally been spending my days and nights working on Yarn this past year, and you really don't get to tell me what should my priorities be - or at least not in this way. Fifth, the problem of this PR is that it's for Windows and I don't use Windows. That doesn't make its priority lower because it's Windows, mind you, but I personally lack a good chunk of context about the problem it fixes and the way it solves it. Ideally someone with Windows should review & merge it, but cf my first point.
Tough luck, I don't know how I'll do without having the joy of receiving your aggressive messages right after getting out of bed. The only one here that has any right to be slightly corrosive would be @briman0094, who actually spend time to help the project. To him I'd like to apologize - anyone else is strongly suggested to stay civil and remember there are human beings behind the screen. End of the digression, back to the topic. |
Hi @arcanis. I do agree with your post, I do not think that you should get flamed. but I also have some comments to it.
I understand that windows users can downgrade, but if no path forward (like an upcomming overhaul that will solve the issues) is presented to a wider audience, then it is practically the same as the issue being ignored. I wish all good things for you and thank you for taking your time. |
I'm sorry for my aggressive words. and apologize to Yarn Team. I have no right push you do so. Yarn is a cross-platform package management. All the Windows users who want add global package(s) will encounter this problem during these two months (even longer). As you can see, many issues refer to this problem including vue.js users. If this issue still remaining, your If you really have no time on solving it. I recommend leaving a message on Yarn Official Website to warn Windows users and put v1.12 msi file on it for them. So that we can avoid this annoying problem. I apologize again for what I saw before. I'm so sorry. |
I’m very sorry to hear that Yarn is maintained by a single, overworked developer! You have my sympathy. As a Windows user, I will be moving back to NPM. It’s a little disingenuous to claim to support Windows when the project is so undersupported that the single dev involved can’t or won’t keep it working on the platform. |
Regarding the main topic: #6954 seems good enough (and easy enough to revert if it breaks something else, which is important) and depending what @zkochan says I'm ok to go with it in the next patch release.
Thanks for your understanding 🙂 we all want things to get better, and I can appreciate that.
It's a bit unfair - note that the problem isn't coming from Yarn, technically speaking, but rather from a third-party package (cmd-shim). Part of the reason why these PRs didn't get merged was that I was hoping that the fix would be made upstream. The whole goal of cmd-shim is precisely to abstract this logic so that we don't have to care about it, after all! 😄
A call for maintainers is a good idea, but we first need to figure out some parts of our governance model before being ready to do it. I've opened #7110 to discuss it further, if you're interested. |
Keeping open until the 1.15.1 ships. @cstrachan88 I prefer to merge the safest PR. The other one instantiates a whole new |
I figured the more complex fix in #6959 would require quite a bit more discussion, hence why I made the bandaid fix in #6954 first ;) I'm absolutely willing to participate in discussion and review of #6959 to evaluate if it's the best solution to the root problem or to see if there's another better solution |
The 1.15.2 (small infra hiccups for the 1.15.1) has just been released - I'd appreciate if someone here could confirm the problem is resolved on your side, then I'll go ahead and close this issue while we work on #6959 🙂 |
It's resolved!! 🎉 |
I can also confirm; after installing 1.15.2, I can run binaries from globally installed packages. Thank you for your efforts in resolving this issue! |
Also confirming 1.15.2 correctly adds global packages. No more shims of shims! |
Awesome 👍 |
the powershell compatibility issue has been fixed, see: yarnpkg/yarn#6902 (comment)
- Yarn's global folder can be set via `yarn config set global-folder` (yarnpkg/yarn#7056) and thus can be persisted. - ~~Since yarn's global bin creating procedure is still problematic (yarnpkg/yarn#6902, **fixed by yarnpkg/yarn#6954 The `.bin` folder in `global\node_modules` is a better path to add to env, and this can avoid the annoying problem when you install scoop in some place except `C:` (that the shims in global bin have wrong relative path pointer). - If you install yarn via `scoop install yarn`, the `Yarn` folder in `$env:LOCALAPPDATA` is useless, and when you uninstall `yarn`, the `.yarnrc` is unused, so the manifest add `uninstaller.script` to remove them when you uninstall. - For reconfiguration, please use `scoop update yarn -f` instead of `scoop reset yarn`. - Close #2969
Due to a fetal issue on Windows' Yarn yarnpkg/yarn#6902, Change packages management to NPM :) Local-installed Taro cli instead of global-installed.
Since the 1.13.0 update, globally installed binaries do not work in PowerShell. The offending commit is 5419606, which is the update to the
cmd-shim
package. The version ofcmd-shim
thatyarn
updated to added default support for PowerShell, meaning that every binary writes a.ps1
shim in addition to the non-extension and the.cmd
ones. It appears Yarn is first callingcmdShim
during the "Linking Dependencies" phase to create the initialbin
shims for the package. This is fine and dandy here, but later in the install step (after thesuccess Installed <package> with binaries
message is printed), Yarn callscmdShim
again once per binary, which causescmdShim
to write a shim for each of the shims. This results in files likebinary.cmd.ps1
,binary.ps1.ps1
, etc, becausecmd-shim
thinks that the base name of the binary is actuallybinary.ps1
. This causes the bash shim to be written tobinary.cmd
andbinary.ps1
, breaking those two shims (PowerShell finds theps1
file which is actually a bash script). Here's a visual afteryarn global add ts-node
:I added a
console.trace
tocmdShim
in my local copy of Yarn to print out the arguments passed, and this is the output:https://gist.github.com/briman0094/d7f256d1158d6e8f96afbb74e85840bb
The text was updated successfully, but these errors were encountered: