truffleruby icon indicating copy to clipboard operation
truffleruby copied to clipboard

TruffleRuby doesnt use a FHS directory structure

Open eregon opened this issue 7 years ago • 10 comments

TruffleRuby doesnt use a FHS directory structure.

This makes it problematic if users want to install to e.g. /usr/local, and if we want to integrate with system package managers such as apt/dnf.

Installing TruffleRuby into a prefix with other software is currently unsupported. TruffleRuby expects to be installed in its own directory, such as ~/.rubies/truffleruby-VERSION.

Reported by @postmodern as ruby-install supports installing to /usr/local.

Along with this, there should also be an uninstaller script so it can be cleanly uninstalled from that prefix.

eregon avatar Jul 12 '18 11:07 eregon

We've got a bin directory - what else do we have or not have that causes the problem?

chrisseaton avatar Jul 12 '18 11:07 chrisseaton

Currently the standalone distribution looks like this:

$ cd truffleruby-1.0.0-rc3
$ tree -L 2
.
├── 3rd_party_licenses_truffleruby.txt
├── bin
│   ├── bundle
│   ├── bundler
│   ├── gem
│   ├── irb
│   ├── rake
│   ├── rdoc
│   ├── ri
│   ├── ruby -> truffleruby
│   ├── testrb
│   └── truffleruby
├── CHANGELOG.md
├── doc
│   ├── legal
│   └── user
├── lib
│   ├── cext
│   ├── json
│   ├── mri
│   ├── patches
│   ├── ruby
│   └── truffle
├── LICENSE_TRUFFLERUBY.md
├── native-image.properties
├── README.md
├── release
└── src
    └── main

The various lib/* directories could conflict with other software (probably should be lib/truffleruby), as well as src/main, and probably so many top-level files is unexpected. doc/ is non-standard in FHS, and probably should be under share/truffleruby.

FWIW, MRI looks like:

$ tree -L 3
.
├── bin
│   ├── erb
│   ├── gem
│   ├── irb
│   ├── rake
│   ├── rdoc
│   ├── ri
│   └── ruby
├── include
│   └── ruby-2.5.0
│       ├── ruby
│       ├── ruby.h
│       └── x86_64-linux
├── lib
│   ├── libruby-static.a
│   └── ruby
│       ├── 2.5.0
│       ├── gems
│       ├── site_ruby
│       └── vendor_ruby
└── share
    ├── doc
    │   └── ruby
    ├── man
    │   └── man1
    └── ri
        └── 2.5.0

eregon avatar Jul 12 '18 12:07 eregon

Right I get the problem then.

chrisseaton avatar Jul 12 '18 12:07 chrisseaton

FWIW @gilles-duboscq was once saying maybe GraalVM could have a layout like this, where all language integrate like in a single prefix following the FHS directory structure. That could be problematic though, as then if ruby is on PATH it would also mean java, js, node, etc would be on PATH which might not be quite right for Ruby users (maybe they want to use a system node/java/python/etc and just have TruffleRuby binaries in PATH. The standalone distribution solves this issue currently, by only including Ruby binaries).

eregon avatar Jul 12 '18 12:07 eregon

When installing the most recent 2 versions (the only ones I've tried) with asdf's asdf-ruby plugin, which uses ruby-build under the hood, I get an error that tells me to come here. It doesn't really seem like a reasonable failure, as: A. I've never tried to install these versions of truffleruby before, so there is no reason for the "directory" to exist, except perhaps as the result if untaring the downloaded file?

The last truffle ruby I installed that worked was:

$ ruby -v
truffleruby 20.0.0, like ruby 2.6.5, GraalVM CE Native [x86_64-darwin]
$ ruby -e 'puts Time.now'
2022-02-17 04:54:04 +0700

though, when I say "worked" only Ruby worked, gem did not.

$ gem -v
/Users/pboling/.asdf/installs/ruby/truffleruby-20.0.0/lib/mri/rubygems/core_ext/kernel_require.rb:54:in `require': Library "/usr/lib/libSystem.B.dylib" does not exist. (RuntimeError)
	from /Users/pboling/.asdf/installs/ruby/truffleruby-20.0.0/lib/mri/rubygems/core_ext/kernel_require.rb:54:in `require'

In any case, here is the build on an Intel Mac running MacOS 12.1:

$ asdf install ruby truffleruby-22.0.0.2
ruby-build: using openssl from homebrew
Downloading truffleruby-22.0.0.2-macos-amd64.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/f49cba9d8dcb1fc2ae95ffb6b325cad8e4697f844945521daf445020202f23b4
Installing truffleruby-22.0.0.2...

ERROR: cannot install TruffleRuby to /Users/pboling/.asdf/installs/ruby/truffleruby-22.0.0.2, which does not look like a valid TruffleRuby prefix
TruffleRuby only supports being installed to a not existing directory or replacing an existing TruffleRuby installation
See https://github.com/oracle/truffleruby/issues/1389 for details

BUILD FAILED (macOS 12.1 using ruby-build 20220125)

Inspect or clean up the working tree at /var/folders/t0/4k0z0s2d6rgb46nh7mlt8_mc0000gn/T/ruby-build.20220217041151.29256.l8rkBR
Results logged to /var/folders/t0/4k0z0s2d6rgb46nh7mlt8_mc0000gn/T/ruby-build.20220217041151.29256.log

Last 10 log lines:
Last-Modified: Tue, 25 Jan 2022 18:19:08 GMT
ETag: "d9035845f66443ff4bd7b41d40c67255-16"
Accept-Ranges: bytes
Server: AmazonS3
X-Cache: Miss from cloudfront
Via: 1.1 906c6b5e83bd44f62b7f603039ce6f30.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: SIN2-C1
X-Amz-Cf-Id: TtnLSqCsV24fzEai4MRyX2me2S2RXVeusVP-uOJr9ak4-LLKzbhUCg==

and

$ asdf install ruby truffleruby-21.3.0
ruby-build: using openssl from homebrew
Downloading truffleruby-21.3.0-macos-amd64.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/3ca0c851386d872239404d41c69f1ba738332eb25da6cf89e157fa1356e68de0
Installing truffleruby-21.3.0...

ERROR: cannot install TruffleRuby to /Users/pboling/.asdf/installs/ruby/truffleruby-21.3.0, which does not look like a valid TruffleRuby prefix
TruffleRuby only supports being installed to a not existing directory or replacing an existing TruffleRuby installation
See https://github.com/oracle/truffleruby/issues/1389 for details

BUILD FAILED (macOS 12.1 using ruby-build 20220125)

Inspect or clean up the working tree at /var/folders/t0/4k0z0s2d6rgb46nh7mlt8_mc0000gn/T/ruby-build.20220217041318.29996.Xc0sON
Results logged to /var/folders/t0/4k0z0s2d6rgb46nh7mlt8_mc0000gn/T/ruby-build.20220217041318.29996.log

Last 10 log lines:
Last-Modified: Tue, 19 Oct 2021 15:08:18 GMT
ETag: "b081fe79c995bd2bdcae093c4ba9b28d-16"
Accept-Ranges: bytes
Server: AmazonS3
X-Cache: Miss from cloudfront
Via: 1.1 729399d6290e74ddd43cb2da1cab5266.cloudfront.net (CloudFront)
X-Amz-Cf-Pop: SIN2-P1
X-Amz-Cf-Id: AKNfFQC3SYVNbzEVP_9_PPrfMiX7SxA_IxrDMv1s87uhTuBpb8Wu3A==

I don't know if the directory it is complaining about existed momentarily during the process, but it doesn't exist after the process exits.

$ ls /Users/pboling/.asdf/installs/ruby/truffleruby-22.0.0.2
ls: /Users/pboling/.asdf/installs/ruby/truffleruby-22.0.0.2: No such file or directory

Note: The instructions in the readme, to install truffleruby-dev with ruby-build did work.

$ ruby-build truffleruby-dev ~/.rubies/truffleruby-dev
ruby-build: using openssl from homebrew
Downloading truffleruby-head-macos-latest.tar.gz...
-> https://github.com/ruby/truffleruby-dev-builder/releases/latest/download/truffleruby-head-macos-latest.tar.gz
Installing truffleruby-head...
Recompiling the OpenSSL C extension (against the installed libssl)
checking for openssl/ssl.h... yes
checking for OpenSSL version is 1.0.1 or later... yes
checking for RAND_egd()... no
# ...

But that doesn't get it linked into asdf... and installing into asdf's expected directory also doesn't quite result in a fully PATH'd working ruby, as asdf is able to see it, but not select it.

pboling avatar Feb 16 '22 21:02 pboling

Maybe asdf is creating an empty directory before installing and that then fails the check? It would be useful if you can come to the GraalVM Slack to help us debug that, otherwise I'll have to install asdf in Docker or so which might take a while.


Regarding truffleruby-dev, what if you install it to ~/.asdf/installs/ruby/truffleruby-dev? Does asdf need any extra step besides having the installation in the right place, besides a rehash? I would hope not, otherwise that's very fragile.

eregon avatar Feb 17 '22 11:02 eregon

@pboling Would you mind filing a separate issue with that asdf error? This issue is not about asdf and I'd rather not mix both.

eregon avatar Feb 17 '22 11:02 eregon

@eregon I disagree; IMO, this is the same issue. The error reported when asdf install fails is this same issue, which you may have missed in the noise (see more in my comments above). I am just piling on here giving another instance of a thing that is not working that I, asdf-ruby and ruby-build (apparently), would expect to work:

ERROR: cannot install TruffleRuby to /Users/pboling/.asdf/installs/ruby/truffleruby-22.0.0.2, which does not look like a valid TruffleRuby prefix
TruffleRuby only supports being installed to a not existing directory or replacing an existing TruffleRuby installation
See https://github.com/oracle/truffleruby/issues/1389 for details

It is possible that this bug is actually with asdf or asdf-ruby somehow... but regardless anyone trying the install is going to be led here by your error message, so this is a fine place to give pointers, I think, re: See https://github.com/oracle/truffleruby/issues/1389 for details

pboling avatar Feb 17 '22 16:02 pboling

@pboling This is a message from ruby-build, and the main purpose is to prevent installing to /usr/local, as that wouldn't work well for many reasons, most of them applying to CRuby, most JVMs and many software BTW. Piling on when the maintainers tell you the issue is separate is never appreciated. This asdf-related issue is not this issue, this issue is about FHS structure, and asdf does NOT need that.

So I think the check in ruby-build is probably too strict here, or asdf/asdf-ruby goes out of its way to create the prefix directory, both seem sensible to fix. Of course it'd be great if asdf-ruby works for truffleruby, we need to figure out the actual issue and how to fix it though. Hence, can you file a separate issue asking for asdf support? As you can see in the README, ruby-build and all other Ruby installers work well, so it's really something special to asdf it seems here. Fixing this will most likely actually involve zero changes in truffleruby itself, hence one could even argue the issue would make more sense on asdf-ruby. But I understand filing it to truffleruby makes sense too.

eregon avatar Feb 17 '22 17:02 eregon

😆 laughing at another project directing people to your issue tracker. I've probably done this myself at some point, but always worth a chuckle. I'll file tickets in other trackers! Thanks for explaining.

pboling avatar Feb 17 '22 21:02 pboling