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

Symlink issue involving bun link #10223

Open
Coachonko opened this issue Apr 12, 2024 · 8 comments
Open

Symlink issue involving bun link #10223

Coachonko opened this issue Apr 12, 2024 · 8 comments
Labels
bug Something isn't working npm Something that relates to the npm-compatible client

Comments

@Coachonko
Copy link

Coachonko commented Apr 12, 2024

What version of Bun is running?

1.1.3+2615dc742

What platform is your computer?

Linux 5.14.0-362.24.1.el9_3.x86_64 x86_64 x86_64

What steps can reproduce the bug?

  1. link monorepo
bun link
bun link v1.1.3 (2615dc74)
Success! Registered "wareme"

To use wareme in a project, run:
  bun link wareme

Or add it in dependencies in your package.json file:
  "wareme": "link:wareme"
  1. add package to repository
bun link @wareme/translations --save
[0.02ms] ".env"
bun link v1.1.3 (2615dc74)

 installed @wareme/translations@link:@wareme/translations

 1 package installed [3.00ms]
  1. project doesn't work. No error messages during bundling, just doesn't work.
ls -lah node_modules/@wareme/
total 12K
drwxr-xr-x.   2 jdb jdb   26 Apr 12 20:14 .
drwxr-xr-x. 242 jdb jdb 8.0K Apr 12 20:14 ..
lrwxrwxrwx.   1 jdb jdb   37 Apr 12 20:14 translations -> ../../../wareme/packages/translations

The arrow shows the file is a symbolic link
4. Remove the symbolic link and manually copy files

rm -rf node_modules/@wareme
cd node_modules
mkdir @wareme
cp -ra ../../../wareme/packages/translations @wareme/

Now everything works.
This confirms Bun has issues with symbolic links.
I have done further, that cannot be as easily replicated, by symbolic-linking the dependency inside the current project src directory, and the result was the exact same.

What is the expected behavior?

Things should work and shouldn't make me doubt my own code for days.

What do you see instead?

Nothing works, am frustrated and angry.

Additional information

Make it work, please.

@Coachonko Coachonko added the bug Something isn't working label Apr 12, 2024
@Coachonko
Copy link
Author

#10218 may be related

@gvilums
Copy link
Contributor

gvilums commented Apr 12, 2024

Related to #10013

@Coachonko
Copy link
Author

Related to #10013

Is it related? I don't even understand what that issue is trying to explain. Also this is a Linux environment

@gvilums
Copy link
Contributor

gvilums commented Apr 14, 2024

Related to #10013

Is it related? I don't even understand what that issue is trying to explain. Also this is a Linux environment

Oops, I mistakenly thought this was an issue related to junctions on windows, and completely missed that this is a linux environment 🤦 . Would it be possible for you to provide a link to the repository where you encountered this issue?

@Coachonko
Copy link
Author

Coachonko commented Apr 15, 2024

There is no specific repository that causes the issue in particular. As described, it seems to be related to the handling of symbolic links.
I have replicated this issue with a number of different packages, linking dependencies in a number of different ways.
If you'd like to follow the steps above you should be able to replicate the issue.

Otherwise, if you really want to clone my repositories, do this (on rocky linux 9.3):

mkdir test && cd test
git clone git@github.com:Coachonko/coachonko.com.git
git clone git@github.com:Coachonko/wareme.git

# remove the dependency from coachonko.com in order to reproduce the issue
sed -i '/"@wareme\/translations": "3.7.2",/d' coachonko.com/package.json

# build the packages
cd wareme/packages/event-emitter && bun run build && cd ../translations && bun run build && cd ../../..

# edit package.json('s) to match npm
# P.S. please either make bun compatible with npm scoped package.json or support git monorepos using bun package.json syntax
sed -i 's/"@wareme\/event-emitter": "workspace:..\/event-emitter"/"@wareme\/event-emitter": "\^3.1.0"/' wareme/packages/translations/package.json
sed -i 's/"name": "translations",/"name": "@wareme\/translations",/g' wareme/packages/translations/package.json
sed -i 's/"name": "event-emitter",/"name": "@wareme\/event-emitter",/g' wareme/packages/event-emitter/package.json

# install dependencies, link package, verify it is a symbolic link
cd coachonko.com && bun install && cd ../wareme/event-emitter && bun link && cd ../wareme/translations && bun link && cd ../../coachonko.com && bun link @wareme/translations && ls -lah node_modules/@wareme/

# create .env and run the project
echo "PORT=8080" > .env && bun run dev:server & bun run dev:browser # or run each in a different terminal instance
# observe how the project fails to run: no errors happen but localhost:8080 serves blank

# kill Bun, remove symbolic link and hard-copy files instead
rm -f node_modules/@wareme/translations
cp -ra ../wareme/packages/* node_modules/@wareme/

# run project again
bun run dev:server & bun run dev:browser
# observe how everything works correctly now: pages are not blank.

@Electroid Electroid added the npm Something that relates to the npm-compatible client label Apr 15, 2024
@Jarred-Sumner
Copy link
Collaborator

Can you provide a more minimal reproduction?

@Jarred-Sumner Jarred-Sumner changed the title Bun cannot handle symbolic links, not even the ones created with bun link Symlink issue involving bun link Apr 24, 2024
@Coachonko
Copy link
Author

I'm not sure how, since the repro requires some manual symbolic linking to be done, or at least some manual operations.

@Coachonko
Copy link
Author

Coachonko commented Jun 1, 2024

This bug is making developing with bun almost impossible, it forces me to cope/paste directories at every change. I have provided extensive information and documented step-by-step reproduction, you have not provided any further information on how you'd like to have a 'more minimal' reproduction.
At this point Bun is just wasting my time instead of helping me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working npm Something that relates to the npm-compatible client
Projects
None yet
Development

No branches or pull requests

4 participants