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

install path of gem executables; bad gem home warning #60

Merged
merged 5 commits into from
Feb 17, 2017
Merged

install path of gem executables; bad gem home warning #60

merged 5 commits into from
Feb 17, 2017

Conversation

pitr-ch
Copy link
Contributor

@pitr-ch pitr-ch commented Feb 11, 2017

connect #59

@pitr-ch pitr-ch mentioned this pull request Feb 11, 2017
7 tasks
.gitignore Outdated
!lib/bin/rdoc
!lib/bin/ri
# Bin directory
bin/**
Copy link
Member

Choose a reason for hiding this comment

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

Just * should be enough

@@ -85,7 +85,7 @@ module RbConfig

if ruby_home
libdir = "#{ruby_home}/lib"
bindir = "#{libdir}/bin"
bindir = "#{ruby_home}/bin"
Copy link
Contributor

Choose a reason for hiding this comment

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

The current bindir is causing me issues when testing gems, so I hope this line change goes in soon.

README.md Outdated
@@ -84,9 +84,11 @@ which can be used to get it working.
The best way to get started with TruffleRuby is via the GraalVM, which includes
compatible versions of everything you need as well as TruffleRuby.

http://www.oracle.com/technetwork/oracle-labs/program-languages/
<http://www.oracle.com/technetwork/oracle-labs/program-languages/>
Copy link
Member

Choose a reason for hiding this comment

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

Why the < >? It seems to make link without as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ha, I've confused the syntax with some other markup.

README.md Outdated

Inside the GraalVM is a `bin/ruby` command that runs TruffleRuby.
See [`doc/user/using-graalvm`](https://github.com/graalvm/truffleruby/tree/master/doc/user/using-graalvm.md)
Copy link
Member

@eregon eregon Feb 17, 2017

Choose a reason for hiding this comment

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

See [Using GraalVM](doc/user/using-graalvm.md)

unset GEM_HOME GEM_PATH GEM_ROOT
```
> **Note:** Ensure you have ruby managers configured properly, see
[`doc/user/ruby-managers`](https://github.com/graalvm/truffleruby/blob/master/doc/user/ruby-managers.md).
Copy link
Member

Choose a reason for hiding this comment

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

This should not be a note, it's a critical step.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the user is following the steps, he has visited the page already and configured it, therefore it was kept as note only. I don't mind either way, changing it.

Copy link
Member

Choose a reason for hiding this comment

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

Users should not need to navigate too much to do one thing. It's also always best to be able to point to a single page and have clear prerequisites.


ruby -rbundler-workarounds -S gem install bundler -v 1.13.7
ruby -r bundler-workarounds -S gem install bundler -v 1.13.7
Copy link
Member

Choose a reason for hiding this comment

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

I like the one argument -rlibrary, it's more convenient to navigate between words at the command line and I believe is the most comment usage over -r library.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's only simple to write, for reading I find it terrible, the word is joined with the option and there is no space for eyes to find the start of the value. I'll keep spaces.

Copy link
Member

Choose a reason for hiding this comment

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

But it's not how users write it, so that's confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's an assumption though, I for example write space even on command line. Since this is a documentation, the more readable option with space separation is a better option then a shortcut.


`bundle exec` does not need the `bundler-workarounds` loaded.

ruby -S bundle exec bin/rails server

Next step: [Playing Optcarrot](https://github.com/graalvm/truffleruby/blob/master/doc/user/optcarrot.md),
Copy link
Member

Choose a reason for hiding this comment

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

How is this related to Installing Gems?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The next step is not meant to imply relation but rather what to read next.

Copy link
Member

Choose a reason for hiding this comment

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

These docs should be each about one thing, not reading pages ;)

@@ -0,0 +1,13 @@
# Playing optcarrot

Clone optcarrot repository.
Copy link
Member

Choose a reason for hiding this comment

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

Clone +the+

git clone https://github.com/mame/optcarrot.git
cd optcarrot

You will need mplayer to be installed, then you can play Lan Master
Copy link
Member

Choose a reason for hiding this comment

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

mplayer

You will need mplayer to be installed, then you can play Lan Master
with following command.

path/to/graalvm-0.20/bin/ruby bin/optcarrot --video mplayer --input term examples/Lan_Master.nes
Copy link
Member

Choose a reason for hiding this comment

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

Did you test it? I never tried with the upstream mame/optcarrot.
There might be issues for input.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah, tested but I forgot I am on a branch, I'll have a look

sure that the manager does not set environment variables `GEM_HOME`, `GEM_PATH`,
and `GEM_ROOT`. The variables are picked up by truffleruby (as any other Ruby
implementation would do) causing truffleruby to pickup wrong gem-home directory
instead of it's own.
Copy link
Member

Choose a reason for hiding this comment

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

+the+ wrong
its own


If you are using a Ruby manager like `rvm`, `rbnev`, or `chruby` make
sure that the manager does not set environment variables `GEM_HOME`, `GEM_PATH`,
and `GEM_ROOT`. The variables are picked up by truffleruby (as any other Ruby
Copy link
Member

Choose a reason for hiding this comment

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

By RubyGems actually but it might easier to simplify as you did.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, every ruby has rubygems by default ...

It will be easier when TruffleRuby can be added to ruby managers, we are working
on it.

Next step: [Installing gems](https://github.com/graalvm/truffleruby/blob/master/doc/user/isntalling-gems.md).
Copy link
Member

Choose a reason for hiding this comment

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

All links can be relative, GitHub handles it nicely and it means it works on branches (test it with the markdown preview in the PR).
BTW, typo in the link here.

@@ -16,6 +16,27 @@
require 'rubygems'
rescue LoadError
else
unless Gem.dir.include?(Truffle::Boot.ruby_home)
Copy link
Member

Choose a reason for hiding this comment

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

I think we should we check the whole Gem.path.
Otherwise RubyGems might still load gems from another Ruby.

bad_gem_home ||= Gem.dir.include?('rvm/gems') && !Gem.dir.include?('rvm/gems/truffleruby')

# chruby stores gem in ~/.gem/<ruby>/<version>
bad_gem_home ||= Gem.dir.include?('.gem') && !Gem.dir.include?('.gems/truffleruby')
Copy link
Member

Choose a reason for hiding this comment

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

Seeing the logic here, how about:

our_gem_home = Gem.default_dir
bad_gem_home = dir != our_gem_home && !dir.include?('/truffleruby/')

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could be, but I wanted to be more precise. I would like the warning not to live for long anyway so we can revisit if it is not removed soon-ish.

Copy link
Member

Choose a reason for hiding this comment

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

The check is not precise though:

I think we should we check the whole Gem.path.
Otherwise RubyGems might still load gems from another Ruby.

Copy link
Member

Choose a reason for hiding this comment

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

i.e. I think my check is more precise and simpler, so please use it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The condition you are suggesting will catch any GEM_HOME change, the old one catches only different GEM_HOME pointing to a gem-home of another ruby in a ruby manager. That is the missing preciseness in the new condition I am referring too. Gem path can be anything, it cannot be easily checked that it's unintentional change and that the path belongs to other ruby. Anyway we need to only detect the common case of misconfigured a ruby manager. We ignore other changes. This will be deleted when truffleruby can be added to ruby managers.

Copy link
Member

@eregon eregon Feb 17, 2017

Choose a reason for hiding this comment

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

Checking Gem.path will show you the warning is always there,
as $HOME/.gem/ruby/2.3.0 is always added by RubyGems, unless GEM_PATH is set
And that's an actual problem as it looks through system Ruby gems if there is a system ruby of version 2.3.x or some other Ruby used that default gem home to install gem (for instance chruby would use that for MRI 2.3.x).
(For instance, bad extensions, conflicting gem versions, etc)
But probably it is less problematic or likely than a bad value for GEM_HOME, so let's merge for now.
The right fix for this default system Ruby path is changing RUBY_ENGINE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah agreed, I am already working on the RUBY_ENGINE fix. Looks promising it should not take too long.

@@ -112,7 +112,7 @@ provide the same interface as JRuby does for this functionality.

Calling Ruby code from Java is supported by the `PolyglotEngine` API of Truffle.

http://lafo.ssw.uni-linz.ac.at/javadoc/truffle/latest/com/oracle/truffle/api/vm/PolyglotEngine.html
<http://lafo.ssw.uni-linz.ac.at/javadoc/truffle/latest/com/oracle/truffle/api/vm/PolyglotEngine.html>
Copy link
Member

Choose a reason for hiding this comment

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

Extra <

@@ -1,37 +1,29 @@
# Installing gems

As mentioned in the
[`README`](https://github.com/graalvm/truffleruby/tree/truffle-head/README.md)
As mentioned in the [README](README.md)
Copy link
Member

Choose a reason for hiding this comment

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

broken link, should be ../../README.md

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ah thanks

bad_gem_home ||= Gem.dir.include?('rvm/gems') && !Gem.dir.include?('rvm/gems/truffleruby')

# chruby stores gem in ~/.gem/<ruby>/<version>
bad_gem_home ||= Gem.dir.include?('.gem') && !Gem.dir.include?('.gems/truffleruby')
Copy link
Member

Choose a reason for hiding this comment

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

The check is not precise though:

I think we should we check the whole Gem.path.
Otherwise RubyGems might still load gems from another Ruby.

* dedicated ruby managers page
* links to next step
* rails compatibility section
* add optcarrot example
@pitr-ch pitr-ch merged commit 4585c0e into oracle:master Feb 17, 2017
chrisseaton pushed a commit that referenced this pull request May 30, 2018
…to master

* commit 'b238d6939a555f31049278a70183e3edc70f2db0':
  Attempt to find the original file to require if a patch is loaded for a gem that hasn't been registered with the patching system.
chrisseaton pushed a commit to Shopify/truffleruby that referenced this pull request Nov 13, 2019
Run minitest in CI

Merge-Requested-By: chrisseaton
Merge-Queue-Digest: 1dbe6365c5da7312dffc2ac8a1de063689089547368b3ef929c10b6a5cbb6926
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.

None yet

4 participants