-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
'lerna bootstrap' fails to symlink binaries which are generated during package build #1444
Comments
This was because of our fix for installation during the monorepo. This is an open problem of Lerna: * lerna/lerna#385 * lerna/lerna#1444
Why not just have the binary files live as raw JS, importing a compiled "implementation" and calling it? That being said, properly-expressed dependencies between the packages should elicit topologically-sorted execution of the lifecycle scripts during bootstrap. I have no experience with |
Yeah, that's we end up doing to work around this, but I still feel lerna's behavior is wrong in this case. As mentioned, if the upstream dependency was obtained through
No, every package is compiled individually (by doing The problem is that |
The problem is that lerna is doing the link action at a time before any package has been built, so it fails to symlink the binaries that will be generated (obviously), and takes to effort to correct that later on.
My apologies for the incorrect assumptions. The bootstrap algorithm is fiendishly complex, but you’re welcome to propose changes to accomplish your goal.
|
I just encountered this bug this past week.
|
If you're using yarn workspaces, the bug you're experiencing is in Yarn, not lerna. `lerna bootstrap` just calls `yarn` in that case.
… On Dec 9, 2018, at 17:02, Jeff Dolle ***@***.***> wrote:
I just encountered this bug this past week.
For others struggling, my temporary solution was to delete the node_modules and reinstall dependencies for the dependent package. And because I use yarn workspaces, deleting the node modules and re-yarning doesn't need to redownload anything.
"fixSymlink": "rm -rf ./node_modules && yarn",
"build": "yarn fixSymlink && someBin",
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
i switched my project from yarn to npm and now am experiencing this problem. |
also, with yarn workspaces, i never needed to use lerna link or bootstrap |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I'm having this issue too. One of my packages is building a bin file during install which never gets symlinked into the sibling packages. |
Also seeing this with Lerna version 3.4.3. |
I actually think an easy way to resolve this is to create the symlinks in the downstream packages, based on what the |
During the 'link' step, if a package's binary targets don't exist yet they will fail to be symlinked, even if a later `run xxx` step would have generated them. This is a situation that occurs in monorepos containing build tools compiled from another language (e.g. TypeScript). Simply adding the symlinks whether the target exists or not is not good enough, as the symlink target needs to be `chmod +x`ed, which is lerna's/npm's responsibility. Instead, if the target doesn't exist, generate a shim shell script that will `chmod` and `exec` the intended target, similar to what would happen on Windows normally. Fixes #1444
https://nodejs.org/api/packages.html#packages_dual_commonjs_es_module_packages Signed-off-by: Liu Bowen <mr_lbw@outlook.com>
We use the static js file to ensure that esw symlink alway work in the other packages when lerna boostraps. Signed-off-by: Liu Bowen <mr_lbw@outlook.com>
We are using TypeScript. As part of the TypeScript "build",
.js
files are generated, some of which are command-line tools.We are doing our TypeScript -> JavaScript compilation in the NPM
"prepare"
phase.However,
lerna bootstrap
does not symlink the binaries that are generated as part of theprepare
phase, because it executeslerna link
once before running theprepare
phases of all targets, and it makes no effort to link later.From
lerna-debug.log
I can tell that it does executepreinstall
for every package before symlinking, but the"preinstall"
phase happens on every machine that installs the package, so is not the correct phase to do our TypeScript compilation in.Reproduction:
In short:
executable
is produced bypkga
and used in the build ofpkgb
. This would have worked ifpkga
was downloaded from NPM, but does not work when the build is managed by Lerna.Expected Behavior
For the build of package
pkgb
, it should not matter whether dependencypkga
is obtained from NPM bynpm install
, or provided bylerna
as part of a monorepo.Current Behavior
Right now it does, because the symlinks to executables are evaluated before packages are event built, so binaries generated during the build are missed.
Possible Solution
A simple fix would be to run
lerna link
again after every package is bootstrapped. This would fix the issue, though it may be bad for performance. If you have enough information in the dependency tree to do selective updates that may be even better.Steps to Reproduce (for bugs)
See the project layout given above.
Proof that this is the issue, running
lerna bootstrap
again now thatexecutable
already exists during thelink
phase:Note that running
lerna bootstrap
multiple times is not a solution, as we might not know in advance how many times we would need to run it! Depends on the amount of packages and the dependencies among them!Context
We are writing packages in TypeScript. Some packages are build tools, containing command-line scripts that need to be run during the build of other packages.
We emphatically DO NOT want to run the build by hand and check in the generated
.js
files.Your Environment
lerna --version
npm --version
node --version
The text was updated successfully, but these errors were encountered: