bun icon indicating copy to clipboard operation
bun copied to clipboard

Bun link works but installs says package is not linked

Open erikkrieg opened this issue 10 months ago • 8 comments

What version of Bun is running?

1.0.0+822a00c4d508b54f650933a73ca5f4a3af9a7983

What platform is your computer?

Darwin 22.6.0 arm64 arm

What steps can reproduce the bug?

  • cd ./link/this/package
  • bun link @custom-scope/package (this matches name in package.json)
  • Change back to root dir
  • ls node_modules/@custom-scope and see package is there
  • bun install fails with error: package "@custom-scope/package" is not linked

What is the expected behavior?

Ideally I shouldn't have to manually run the link command at all since the path to the linked directory is in the root package.json and then in either case the install should not fail claiming the link does not exist when it actually does.

What do you see instead?

I see the symlink in node_modules, but the install command always fails.

Additional information

I installed the bun binary using Nix package manager. I don't think this is likely to matter, since it is just copying the built binary from Bun's GitHub releases, but just to be thorough I'm mentioning it.

Another thing, the custom scope being used for the linked module is the same as a scope that points to a private registry. So I'm wondering if there could be an unexpected dynamic involving this.

erikkrieg avatar Sep 09 '23 18:09 erikkrieg

Also hitting this.

We have this in our root package.json under "devDependencies":

    "eslint-plugin-stainless": "link:./lib/eslint-plugin-stainless",

and the contents of ./lib/eslint-plugin-stainless/package.json is as follows:

{
  "name": "eslint-plugin-stainless",
  "version": "1.0.0",
  "main": "./index.js"
}

here's what I run and see:

[11:57:03] [~/code/stainless] [main]
➜  cd lib/eslint-plugin-stainless 

[11:57:06] [~/code/stainless/lib/eslint-plugin-stainless] [main]
➜  bun link
bun link v1.0.0 (822a00c4)
Success! Registered "eslint-plugin-stainless"

To use eslint-plugin-stainless in a project, run:
  bun link eslint-plugin-stainless

Or add it in dependencies in your package.json file:
  "eslint-plugin-stainless": "link:eslint-plugin-stainless"

[11:57:11] [~/code/stainless/lib/eslint-plugin-stainless] [main]
➜  cd -
~/code/stainless

[11:57:25] [~/code/stainless] [main]
➜  bun link eslint-plugin-stainless
bun link v1.0.0 (822a00c4)

 installed eslint-plugin-stainless@link:eslint-plugin-stainless

patch-package 8.0.0
Applying patches...
[email protected] ✔

 6 packages installed [3.31s]

[11:57:36] [~/code/stainless] [main]
➜  bun install
bun install v1.0.0 (822a00c4)


error: package "eslint-plugin-stainless" is not linked

To install a linked package:
   bun link my-pkg-name-from-package-json

Tip: the package name is from package.json, which can differ from the folder name.

rattrayalex avatar Sep 10 '23 15:09 rattrayalex

I have the same issue, not sure how to fix this

CleanShot 2023-09-12 at 08 21 33@2x

CleanShot 2023-09-12 at 08 21 10

preshonyee avatar Sep 12 '23 07:09 preshonyee

Same issue

package.json

  "dependencies": {
    "@sketch/shared-types": "link:./src/shared_types",
image

devonpmack avatar Sep 12 '23 20:09 devonpmack

same here :)

    "eslint-plugin-lenus-mobile-custom-rules": "link:./packages/mobile-eslint-rules",

Nasseratic avatar Sep 13 '23 09:09 Nasseratic

Seeing the same issue here. I've tried using bun link <package-name> in the app directory and adding <package-name>: link:<package-name> to package.json. Neither seems to work.

jlamoreaux avatar Sep 13 '23 18:09 jlamoreaux

Hey, also facing this issue, the bun link says it has linked the package but then after a bun install it says that it's not linked. 😭

Parsifal-M avatar Sep 15 '23 13:09 Parsifal-M

I experience same issue but weirdly it works on one my repos but not the second one. I linked a lib called damageCalc in repo A later that week i linked it in repo B as well. It works on Repo A but not Repo B

Edit: Library is TS, Repo A is JS and Repo B is TS. So when i convert the files into JS on Repo B they "magically" work. Then I thought it might be my error and tested on my other computer. It links correct on my linux computer and typing definitions resolve as well. The machine with error is an M1 Mac.

alchemistake avatar Nov 11 '23 22:11 alchemistake

The fix for me was putting the new "file:" prefix instead of "link:" in package.json for the linked dependencies. Found here

bitofbreeze avatar Apr 06 '24 13:04 bitofbreeze

I confirm the same issue. I also tried mentioned suggestions above but none of them worked for me.

sohaieb avatar Apr 25 '24 21:04 sohaieb