mflatt / raco-cross

4 stars 0 forks source link

`raco cross` overwrites binaries of host platform with binaries of target platform #3

Closed sschwarzer closed 3 years ago

sschwarzer commented 3 years ago

First my observation, starting from a freshly installed Racket 8.1 cs of Fedora Linux 33.

The Racket installation is at /home/schwa/sd/racket/current, which is a symlink to /home/schwa/sd/racket/8.1 (only the last path component differs).

/home/racket/current/bin is in my $PATH:

schwa@warpy:~/sd/racket$ which raco
~/sd/racket/current/bin/raco
schwa@warpy:~/sd/racket$ which racket
~/sd/racket/current/bin/racket

The installation of raco-cross seems to go ok:

schwa@warpy:~/sd/racket$ raco pkg install raco-cross
Resolving "raco-cross" via https://download.racket-lang.org/releases/8.1/catalog/
Resolving "raco-cross" via https://pkgs.racket-lang.org
Using cached16242032951624203295298 for https://github.com/racket/raco-cross.git?path=raco-cross
The following uninstalled packages are listed as dependencies of raco-cross:
   raco-cross-lib
   raco-cross-doc
Would you like to install these dependencies? [Y/n/a/c/?] y
00: Resolving "raco-cross-lib" via https://download.racket-lang.org/releases/8.1/catalog/
00: Resolving "raco-cross-lib" via https://pkgs.racket-lang.org
Resolving "raco-cross-doc" via https://download.racket-lang.org/releases/8.1/catalog/
Resolving "raco-cross-doc" via https://pkgs.racket-lang.org
Using cached16242032951624203295298 for https://github.com/racket/raco-cross.git?path=raco-cross-lib
Using cached16242032951624203295298 for https://github.com/racket/raco-cross.git?path=raco-cross-doc
The following uninstalled packages were listed as dependencies
and they were installed:
 dependencies of raco-cross:
   raco-cross-lib
   raco-cross-doc
raco setup: version: 8.1
raco setup: platform: x86_64-linux [cs]
raco setup: target machine: ta6le
raco setup: installation name: 8.1
raco setup: variants: cs
raco setup: main collects: /home/schwa/sd/racket/current/collects/
raco setup: collects paths:
raco setup:   /home/schwa/.local/share/racket/8.1/collects
raco setup:   /home/schwa/sd/racket/current/collects/
raco setup: main pkgs: /home/schwa/sd/racket/current/share/pkgs
raco setup: pkgs paths:
raco setup:   /home/schwa/sd/racket/current/share/pkgs
raco setup:   /home/schwa/.local/share/racket/8.1/pkgs
raco setup: links files:
raco setup:   /home/schwa/sd/racket/current/share/links.rktd
raco setup:   /home/schwa/.local/share/racket/8.1/links.rktd
raco setup: main docs: /home/schwa/sd/racket/current/doc
raco setup: --- updating info-domain tables ---                    [17:45:04]
raco setup: updating: /home/schwa/.local/share/racket/8.1/share/info-cache.rktd
raco setup: --- pre-installing collections ---                     [17:45:04]
raco setup: --- installing foreign libraries ---                   [17:45:04]
raco setup: --- installing shared files ---                        [17:45:04]
raco setup: --- compiling collections ---                          [17:45:04]
raco setup: --- parallel build using 4 jobs ---                    [17:45:04]
raco setup: 3 making: <pkgs>/raco-cross-doc
raco setup: 2 making: <pkgs>/raco-cross-lib
raco setup: 2 making: <pkgs>/raco-cross-lib/private
raco setup: 2 making: <pkgs>/raco-cross-lib/private/cross
raco setup: 3 making: <pkgs>/raco-cross-doc/private
raco setup: --- creating launchers ---                             [17:45:06]
raco setup: --- installing man pages ---                           [17:45:06]
raco setup: --- building documentation ---                         [17:45:06]
raco setup: 1 running: <pkgs>/racket-index/scribblings/main/user/local-redirect.scrbl
raco setup: 0 running: <pkgs>/raco-cross-doc/private/cross/raco-cross.scrbl
raco setup: 1 running: <pkgs>/racket-index/scribblings/main/user/release.scrbl
raco setup: 2 running: <pkgs>/racket-index/scribblings/main/user/search.scrbl
raco setup: 1 running: <pkgs>/racket-index/scribblings/main/user/start.scrbl
raco setup: 3 rendering: <pkgs>/racket-index/scribblings/main/user/local-redirect.scrbl
raco setup: 2 rendering: <pkgs>/raco-cross-doc/private/cross/raco-cross.scrbl
raco setup: 1 rendering: <pkgs>/racket-index/scribblings/main/user/release.scrbl
raco setup: 0 rendering: <pkgs>/racket-index/scribblings/main/user/search.scrbl
raco setup: 1 rendering: <pkgs>/racket-index/scribblings/main/user/start.scrbl
raco setup: --- installing collections ---                         [17:45:11]
raco setup: --- post-installing collections ---                    [17:45:11]

Then I do

schwa@warpy:~/sd/racket$ raco cross --target x86_64-win32 pkg install --deps search-auto sexp-diff-lib
>> Cross configuration
 Target:    x86_64-win32
 Host:      x86_64-linux
 Version:   8.1
 VM:        cs
 Workspace: /home/schwa/.local/share/racket/raco-cross/8.1
>> Downloading and unpacking
 https://mirror.racket-lang.org/installers/8.1/racket-minimal-8.1-src-builtpkgs.tgz
>> Downloading and unpacking
 https://mirror.racket-lang.org/installers/8.1/racket-minimal-8.1-x86_64-linux-cs.tgz

...

Resolving "sexp-diff-lib" via https://download.racket-lang.org/releases/8.1/catalog/
Resolving "sexp-diff-lib" via https://pkgs.racket-lang.org
Using cached16242037131624203713892 for https://github.com/stamourv/sexp-diff.git?path=sexp-diff-lib
raco setup: version: 8.1
raco setup: platform: win32\x86_64 [cs]
raco setup: target machine: ta6nt
raco setup: cross-installation: yes
raco setup: installation name: 8.1
raco setup: variants: cs 
raco setup: main collects: /home/schwa/.local/share/racket/raco-cross/8.1/x86_64-win32-cs/collects/
raco setup: collects paths:
raco setup:   /home/schwa/.local/share/racket/raco-cross/8.1/x86_64-win32-cs/collects/
raco setup: main pkgs: /home/schwa/.local/share/racket/raco-cross/8.1/x86_64-win32-cs/share/pkgs
raco setup: pkgs paths:  
raco setup:   /home/schwa/.local/share/racket/raco-cross/8.1/x86_64-win32-cs/share/pkgs
raco setup:   /home/schwa/.local/share/racket/8.1/pkgs
raco setup: links files: 
raco setup:   /home/schwa/.local/share/racket/raco-cross/8.1/x86_64-win32-cs/share/links.rktd
raco setup:   /home/schwa/.local/share/racket/8.1/links.rktd
raco setup: compiled-file roots:
raco setup:   /home/schwa/.local/share/racket/raco-cross/8.1/x86_64-win32-cs/build/zo
raco setup:   same
raco setup: main docs: /home/schwa/.local/share/racket/raco-cross/8.1/x86_64-win32-cs/doc
raco setup: --- updating info-domain tables ---                    [17:48:31]
raco setup: --- pre-installing collections ---                     [17:48:31]
raco setup: --- installing foreign libraries ---                   [17:48:31]
raco setup: --- installing shared files ---                        [17:48:31]
raco setup: --- compiling collections ---                          [17:48:31]
raco setup: --- parallel build using 4 jobs ---                    [17:48:31]
raco setup: 3 making: <pkgs>/sexp-diff-lib/sexp-diff
raco setup: --- creating launchers ---                             [17:48:43]
raco setup: --- installing collections ---                         [17:48:43]
raco setup: --- post-installing collections ---                    [17:48:43

It's a bit suspicious to me that pkgs paths contains /home/schwa/.local/share/racket/8.1/pkgs.

After the installation of sexp-diff-lib, raco cross --browse no longer works:

schwa@warpy:~/sd/racket$ raco cross --browse
fasl-read: incompatible fasl-object machine-type 'ta6nt found in #<binary input port bytevector>
  context...:
   body of data
   /home/schwa/sd/racket/current/collects/raco/raco.rkt:41:0
   body of "/home/schwa/sd/racket/current/collects/raco/raco.rkt"
   body of "/home/schwa/sd/racket/current/collects/raco/main.rkt"

Before running raco cross --target x86_64-win32 pkg install --deps search-auto sexp-diff-lib, I made a copy of the host packages:

schwa@warpy:~/.local/share/racket$ cp -pr 8.1 8.1-orig

When I make a diff of the directories 8.1-orig and 8.1 (modified by the raco cross sexp-diff-lib installation) with

schwa@warpy:~/.local/share/racket$ diff -ur 8.1-orig/ 8.1 > diff.txt

I get the attached output.

diff.txt

Please let me know if you need more information.

sschwarzer commented 3 years ago

In case it matters, here's how Racket was installed:

schwa@warpy:~/sd/racket$ sh ~/distfiles/racket-8.1-x86_64-linux-cs.sh
This program will extract and install Racket v8.1.

Note: the required diskspace for this installation is 658M.

Do you want a Unix-style distribution?
  In this distribution mode files go into different directories according
  to Unix conventions.  A "racket-uninstall" script will be generated
  to be used when you want to remove the installation.  If you say 'no',
  the whole Racket directory is kept in a single installation directory
  (movable and erasable), possibly with external links into it -- this is
  often more convenient, especially if you want to install multiple
  versions or keep it in your home directory.
Enter yes/no (default: no) >

Where do you want to install the "racket" directory tree?
  1 - /usr/racket [default]
  2 - /usr/local/racket
  3 - ~/racket (/home/schwa/racket)
  4 - ./racket (here)
  Or enter a different "racket" directory to install in.
> 8.1

Checking the integrity of the binary archive... ok.
Unpacking into "/home/schwa/sd/racket/8.1" (Ctrl+C to abort)...
Done.

If you want to install new system links within the "bin", "man"
  and "share/applications" subdirectories of a common directory prefix
  (for example, "/usr/local") then enter the prefix of an existing
  directory that you want to use.  This might overwrite existing symlinks,
  but not files.
(default: skip links) >

Installation complete.
mflatt commented 3 years ago

Did you possibly run raco cross --target x86_64-win32 setup along the way? I don't quite see how so much of a user-scope raco-cross installation got rebuilt.

But maybe it doesn't matter. The issue is that the different installations have the same name, and so they have the same user area. (I haven't run into this mainly because I generally use installation scope for packages, including the Racket that I use to run raco cross.) Probably, in addition to setting a cross installation to use installation scope for package, the installation's name should be configured to fully identify the configuration: version plus target plus VM.

[Note: the package has migrated to racket/raco-cross, but it appears that I can't reassign the issue to a repo under a different user or organization.]

mflatt commented 3 years ago

I should note that the change applies to new target installations, but it will not affect existing target installations. (Use --remove to remove a target.)

sschwarzer commented 3 years ago

Thanks for the quick reply.

Did you possibly run raco cross --target x86_64-win32 setup along the way?

Not that I know of. Could it be a side effect from installing dependencies?

Oh, I now see that that there's a raco cross option --skip-setup. Is this about a different form of setup compared to raco cross --target <target> setup?

The issue is that the different installations have the same name

What does the "name" of an installation mean? Is this the leaf directory where the installation archive is unpacked (in my case 8.1)? (Seems not, if I make the installation to 8.1-x86_64-linux-cs instead of 8.1, I still get the raco cross --browse failure.)

and so they have the same user area

To clarify, the user area (if I understand the term correctly) is ~/.local/share/racket/8.1 whereas raco-cross seems to work on ~/.local/share/racket/raco-cross/8.1. I thought that files for different targets are written only to the latter directory (and/or subdirectories).

I haven't run into this mainly because I generally use installation scope for package

Ok, this works for me as well. In case someone comes across this ticket and is looking for more information, it's possible to set the default installation scope to "installation" with: raco pkg config -i --set default-scope installation , see https://docs.racket-lang.org/pkg/FAQ.html .

[Note: the package has migrated to racket/raco-cross, but it appears that I can't reassign the issue to a repo under a different user or organization.]

Thanks for the heads-up about the move. I see you have changed the README now. :-)

mflatt commented 3 years ago

Ah, you're right that the setup phase (related to --skip-setup) is how the user-scope setup would have happened.

For more on installation names, see https://docs.racket-lang.org/raco/config-file.html#(idx._(gentag._68._(lib._scribblings%2Fraco%2Fraco..scrbl)))