Skip to content

Commit

Permalink
Support Darwin bash in bin/yarn (#6568)
Browse files Browse the repository at this point in the history
* Support Darwin bash in bin/yarn

If the yarn binary is a symlink the `basepath` is not correctly resolved on OSX/Darwin.

For example take the following structure:
```
vendor/yarnpkg/yarn
vendor/bin/yarn -> ../yarnpkg/yarn/bin/yarn
```

And run yarn:
```
$ yarn
internal/modules/cjs/loader.js:582
    throw err;
    ^

Error: Cannot find module '/Users/yarnpkg/yarn/bin/yarn.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)
```
Since the symlink is not resolved the relative path in the symlink leads to the wrong path.

This PR, fixes that issue.

* Update CHANGELOG.md
  • Loading branch information
Hidde Boomsma authored and arcanis committed Oct 23, 2018
1 parent f6d0a5b commit af72e6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -40,6 +40,10 @@ Please add one entry in this file for each change in Yarn's behavior. Use the sa

[#6562](https://github.com/yarnpkg/yarn/pull/6562) - [**Bertrand Marron**](https://github.com/tusbar)

- Fixes Yarn invocations on Darwin when the `yarn` binary was symlinked

[#6568](https://github.com/yarnpkg/yarn/pull/6568) - [**Hidde Boomsma**](https://github.com/hboomsma)

- Fixes `require.resolve` when used together with the `paths` option

[#6565](https://github.com/yarnpkg/yarn/pull/6565) - [**Maël Nison**](https://twitter.com/arcanis)
Expand Down
1 change: 1 addition & 0 deletions bin/yarn
Expand Up @@ -3,6 +3,7 @@ argv0=$(echo "$0" | sed -e 's,\\,/,g')
basedir=$(dirname "$(readlink "$0" || echo "$argv0")")

case "$(uname -s)" in
Darwin) basedir="$( cd "$( dirname "$argv0" )" && pwd )";;
Linux) basedir=$(dirname "$(readlink -f "$0" || echo "$argv0")");;
*CYGWIN*) basedir=`cygpath -w "$basedir"`;;
*MSYS*) basedir=`cygpath -w "$basedir"`;;
Expand Down

0 comments on commit af72e6a

Please sign in to comment.