Skip to content

Comments

Fix symbolic links to sccache on linux#2420

Closed
sertonix wants to merge 1 commit intomozilla:mainfrom
sertonix:symlinks
Closed

Fix symbolic links to sccache on linux#2420
sertonix wants to merge 1 commit intomozilla:mainfrom
sertonix:symlinks

Conversation

@sertonix
Copy link
Contributor

@sertonix sertonix commented Jul 5, 2025

Whether or not env::current_exe follows symlinks is platform dependant. On linux it follows them which made it impossible to do things like ln -s sccache /usr/bin/cc. By reading env::args() directly we don't have this issue.

Fixes #993
Based on rivy/rs.coreutils@ad3852a

@sertonix
Copy link
Contributor Author

@sylvestre Could you take a look at this?

@sylvestre
Copy link
Collaborator

@sertonix could you please add a test to make sure we don't regress? thanks

@codecov-commenter
Copy link

codecov-commenter commented Aug 13, 2025

Codecov Report

❌ Patch coverage is 66.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 70.27%. Comparing base (36c8b89) to head (1da6705).

Files with missing lines Patch % Lines
src/cmdline.rs 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2420      +/-   ##
==========================================
+ Coverage   67.31%   70.27%   +2.96%     
==========================================
  Files          64       65       +1     
  Lines       35165    35525     +360     
==========================================
+ Hits        23670    24964    +1294     
+ Misses      11495    10561     -934     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.


if !internal_start_server {
if let Ok(exe) = env::current_exe() {
if let Ok(exe) = match env::args().next() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to mention the platform-dependent symlink following issue here in a comment instead of only in the commit message. This code looks a bit mysterious otherwise. Much more convenient not to have to use git blame or so to find that important info.

I hope this gets merged btw, this issue is a strange papercut that gives a bad/unfinished first impression.

@sertonix
Copy link
Contributor Author

could you please add a test to make sure we don't regress?

I would like to but I am uncertain how to do this.

@ahartmetz
Copy link
Collaborator

could you please add a test to make sure we don't regress?

I would like to but I am uncertain how to do this.

I've had the same problem, but it's often not as hard as it looks.

  • What is not supposed to happen?
  • How do you make it happen? (Probably with Rust filesystem API to create the symlink and existing sccache test infrastructure to create a temp dir, run a test compile... have a look around)
  • How do you check if it happened? (Probably success or failure of compiling a file)
  • Run tests with and without the fix to (more or less) verify that they both work

@ahartmetz
Copy link
Collaborator

@sertonix If you're motivated to finish it, you could come to the sccache Matrix channel and ask for help. I'm sometimes on there as well. https://chat.mozilla.org/#/room/#sccache:mozilla.org (or translate it to the usual Matrix "coordinates" in your client if you have one)

Whether or not env::current_exe follows symlinks is platform dependant.
On linux it follows them which made it impossible to do things like
ln -s sccache /usr/bin/cc. By reading env::args() directly we don't
have this issue.

Fixes mozilla#993
Based on rivy/rs.coreutils@ad3852a
@ahartmetz
Copy link
Collaborator

@sertonix If you don't mind, I can have a whack at writing a test for this

@sertonix
Copy link
Contributor Author

sertonix commented Sep 6, 2025

It might take a while before I get to writing tests so feel free to give it a try. I pushed a small fix that I made while using this patch

@ahartmetz
Copy link
Collaborator

I think you can close this one.

@sertonix
Copy link
Contributor Author

Right

@sertonix sertonix closed this Sep 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Symbolic link doesn't seem to work on Linux

4 participants