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

2.10.0-M3 shell script wrappers do not resolve relative symlinks #5792

Closed
scabug opened this Issue May 12, 2012 · 8 comments

Comments

Projects
None yet
2 participants
@scabug
Copy link

scabug commented May 12, 2012

In MacPorts we install symlinks into $prefix/bin for all the shell scripts. The symlinks are relative, so scala is a symlink to ``../share/scala-2.10/bin/` instead of using an absolute symlink (makes it slightly more relocatable.) This works in 2.9 and breaks in 2.10. The 2.10 code works if one is cd'ed into the directory where the symlink resolved, but most times people are not cd'ed into $prefix/bin.

  • This works:
    cd /tmp
    tar xvfz /opt/local/var/macports/distfiles/scala29/scala-2.9.2.tgz
    mkdir bin
    cd bin
    ln -sf ../scala-2.9.2/bin/scala .
    cd /
    /tmp/bin/scala

  • This doesn't work:
    cd /tmp
    tar xvfz /opt/local/var/macports/distfiles/scala210/scala-2.10.0-M3.tgz
    mkdir bin
    cd bin
    ln -sf ../scala-2.10.0-M3/bin/scala .
    cd /
    /tmp/bin/scala

Returns

/tmp/bin/scala: line 15: cd: ../scala-2.10.0-M3/bin/..: No such file or directory
Error: Could not find or load main class scala.tools.nsc.MainGenericRunner

I'll change the symlinks in MacPorts to absolute.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 12, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5792?orig=1
Reporter: @blair
Affected Versions: 2.10.0-M3

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 13, 2012

@paulp said:
I do not think this is scala's issue per se. What I see is that it works fine unless you use /tmp specifically, because /tmp itself is a symlink to /private/tmp.

That means if you do this:

cd /tmp
mkdir bin
cd bin
ln -s ../path/to/scala

You create a bogus symlink, because bash (wildly guessing you're using bash) "helpfully" resolves .. according to the path by which you arrived. It acts as if you're in /tmp/bin, but you're in /private/tmp/bin.

To verify this is the problem, try it from /private/tmp instead of /tmp and I think you'll find it works. (At least, I do.)

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 13, 2012

@paulp said:
Closing as not a bug; let me know if you still have reason to believe otherwise.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 13, 2012

@blair said:
Hi Paul,

I tried this on my Ubuntu 12.04 system with /tmp being a real directory and I got the same error.

Blair

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 13, 2012

@paulp said:
Now having seen it work on multiple systems, I stand by the assessment. You will need something pretty convincing to make me disbelieve this.


% pwd
/tmp/bin

% ln -s ../../local/scala/scala-2.10.0-M3/bin/scala .
% ls -la
total 140
drwxrwxr-x   2 ec2-user ec2-user   4096 May 13 07:32 .
drwxrwxrwt 152 root     root     135168 May 13 07:29 ..
lrwxrwxrwx   1 ec2-user ec2-user     43 May 13 07:32 scala -> ../../local/scala/scala-2.10.0-M3/bin/scala

% ./scala
Welcome to Scala version 2.10.0-M3 (OpenJDK 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

% cd /
% /tmp/bin/scala
Welcome to Scala version 2.10.0-M3 (OpenJDK 64-Bit Server VM, Java 1.6.0_22).
Type in expressions to have them evaluated.
Type :help for more information.

% uname -a
Linux
@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 13, 2012

@blair said:
Not re-opening until I can prove this ;)

Is local at /local? In that case, I believe the symlink's leading ..'s will go back to / so it'll continue to work. With your current test of the scala symlink, can you cd somewhere deeper and try it, say /usr/share/doc, where ../.. doesn't take you to /.

@scabug

This comment has been minimized.

Copy link
Author

scabug commented May 13, 2012

@paulp said:
You got it. Maybe fixed in 4cd0253d0d . I won't be winning any awards for the code but it should only arise in this slightly perverse scenario so if it works for you then it works.

@scabug scabug closed this May 13, 2012

@scabug

This comment has been minimized.

Copy link
Author

scabug commented Jun 1, 2012

Peter Vlugter (pvlugter) said:
Was looking for the latest in resolving script paths and found my way to this issue.

If you take an even more perverse scenario:

relative/scala -> ../bin/scala
relative/again/scala -> ../scala

with multiple relative symlinks, then the fix in 4cd0253d0d also won't work.

Just trying something now that could be better. Will put it in a pull request.

@scabug scabug added the regression label Apr 7, 2017

@scabug scabug added this to the 2.10.0-M3 milestone Apr 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.