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

conda-forge's ruby attempts to install gens in the global system directory #7

Open
SylvainCorlay opened this issue Mar 2, 2018 · 21 comments

Comments

@SylvainCorlay
Copy link
Member

I guess that it should use some directory under the PREFIX path.

@scopatz
Copy link
Member

scopatz commented Mar 2, 2018

Prs welcome!

@SylvainCorlay
Copy link
Member Author

Prs welcome!

Did you make a bot for this? 😄

@scopatz
Copy link
Member

scopatz commented Mar 2, 2018

hahah now that is a great idea 😉

@SylvainCorlay
Copy link
Member Author

That said, it is probably a matter of figuring out another option at the configure step. I will try to see if I can find it... althougglh I am not a Ruby person.

@scopatz
Copy link
Member

scopatz commented Mar 2, 2018

Yeah, I am not a ruby person either. I was just trying to fiddle around with it and so I mad the package.

@carlodri
Copy link

not a ruby person either...but this SO answer says something like:

export GEM_HOME="$PREFIX/<ruby version>/gems"
export GEM_PATH="$GEM_HOME"

@jakirkham
Copy link
Member

So activate/deactivate scripts would be one option. Is there an RC file solution?

@SylvainCorlay
Copy link
Member Author

I wonder if this could be set at build time, so that we don't need environment variable.

@scopatz
Copy link
Member

scopatz commented Sep 17, 2018

Yeah that would nice if it could be. I think I hunted around for something like that originally and didn't find anything. Maybe I missed it or things have changed

@jimmynguyc
Copy link
Contributor

So activate/deactivate scripts would be one option. Is there an RC file solution?

You can specify the gemhome in /etc/gemrc, /usr/local/etc/gemrc or ~/.gemrc

gemhome: /usr/local/.gems

@SylvainCorlay
Copy link
Member Author

Awesome. Would ruby pick up thay rc file in INSTALL_PREFIX/etc?

@jimmynguyc
Copy link
Contributor

I don't think so. It tries to get it in those locations (https://github.com/rubygems/rubygems/blob/master/lib/rubygems/config_file.rb#L32-L37) or from the GEMRC environment variable.

@scopatz
Copy link
Member

scopatz commented Sep 20, 2018

Well, this recipe could patch SYSTEM_CONFIG_PATH in that file to instead look in $PATH

@scopatz
Copy link
Member

scopatz commented Sep 20, 2018

Sorry, look in $PREFIX

@jakirkham
Copy link
Member

That should be pretty easy to do.

We do something applicable here in fontconfig as well. Basically we apply a patch, which makes it easy to replace the value with sed during the build. conda-build should pick up on the hard-coded path in the text file during packaging and stub it out for replacement at install time.

@jimmynguyc
Copy link
Contributor

According to this and this SYSTEM_CONFIG_PATH should default to $(prefix)/etc?

@wolfv
Copy link
Member

wolfv commented Sep 22, 2020

trying this now.

@wolfv
Copy link
Member

wolfv commented Sep 22, 2020

I added the following to the bottom of the build.sh script:

mkdir -p $PREFIX/etc
mkdir -p $PREFIX/share/rubygems/

echo "gemhome: ${PREFIX}/share/rubygems" > $PREFIX/etc/gemrc

and it seems to work.

There are two issues though:

  • the $PREFIX/share/rubygems/bin paths isn't added to $PATH, we could do that through an activate script
  • I get some issue when trying to execute the gem's bin:
(ruby) ~/Programs/recipes/ruby-feedstock:271_windows$ ~/miniconda3/envs/ruby/share/rubygems/bin/jekyll 
Traceback (most recent call last):
	2: from /home/wolfv/miniconda3/envs/ruby/share/rubygems/bin/jekyll:23:in `<main>'
	1: from /home/wolfv/miniconda3/envs/ruby/lib/ruby/2.7.0/rubygems.rb:294:in `activate_bin_path'
/home/wolfv/miniconda3/envs/ruby/lib/ruby/2.7.0/rubygems.rb:275:in `find_spec_for_exe': can't find gem jekyll (>= 0.a) with executable jekyll (Gem::GemNotFoundException)

Any ideas for the latter?

@wolfv
Copy link
Member

wolfv commented Sep 22, 2020

OK when I set export GEM_HOME=$CONDA_PREFIX/share/rubygems/ it works! 🎉

Maybe we should have an activate script for that? or can we add that to gemrc as well...

@scopatz
Copy link
Member

scopatz commented Sep 22, 2020

Yeah we should have an activate script for that

@martibosch
Copy link

I am having an issue running bundler:

I have installed ruby (v3.1.2) using mamba, then installed bundler using gem (note that which gem gives me /home/martibosch/mambaforge/bin/gem in my base mamba env). Then, running bundle exec jekyll serve (or any bundle command basically) gives me

/home/martibosch/mambaforge/share/rubygems/bin/bundle: 6: exec: /home/martibosch/mambaforge/share/rubygems/bin/ruby: not found

so it is basically looking for ruby at mambaforge/share/rubygems/bin whereas ruby is at /home/martibosch/mambaforge/bin/ruby.

I have not changed anything so this is basically vanilla ruby installation from conda-forge, i.e., with etc/conda/activate.d/ruby_activate.sh being:

export GEM_HOME=$CONDA_PREFIX/share/rubygems/
export PATH="$CONDA_PREFIX/share/rubygems/bin:$PATH"

giving me a $PATH of

/home/martibosch/mambaforge/share/rubygems/bin:/home/martibosch/mambaforge/bin:/home/martibosch/mambaforge/share/rubygems/bin:/home/martibosch/mambaforge/condabin:/home/martibosch/.local/bin:...<bunch-of-no-mamba-stuff>

How can I thus use bundler with conda-forge ruby?

Thank you. Best,
Martí

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

No branches or pull requests

7 participants