Scala Programming Language
  1. Scala Programming Language
  2. SI-5792

2.10.0-M3 shell script wrappers do not resolve relative symlinks

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Scala 2.10.0-M3
    • Fix Version/s: Scala 2.10.0-M3
    • Component/s: Packaging
    • Labels:
    • Environment:

      Mac OS X 10.7.4.

      Description

      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.

      1. 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
      1. 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.

        Activity

        Hide
        Paul Phillips added a comment -

        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.)

        Show
        Paul Phillips added a comment - 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.)
        Hide
        Paul Phillips added a comment -

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

        Show
        Paul Phillips added a comment - Closing as not a bug; let me know if you still have reason to believe otherwise.
        Hide
        Blair Zajac added a comment -

        Hi Paul,

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

        Blair

        Show
        Blair Zajac added a comment - Hi Paul, I tried this on my Ubuntu 12.04 system with /tmp being a real directory and I got the same error. Blair
        Hide
        Paul Phillips added a comment -

        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
        
        Show
        Paul Phillips added a comment - 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
        Hide
        Blair Zajac added a comment -

        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 /.

        Show
        Blair Zajac added a comment - 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 /.
        Hide
        Paul Phillips added a comment -

        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.

        Show
        Paul Phillips added a comment - 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.
        Hide
        Peter Vlugter added a comment -

        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.

        Show
        Peter Vlugter added a comment - 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.

          People

          • Assignee:
            Paul Phillips
            Reporter:
            Blair Zajac
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development