western-bioinfo / western-bioinfo.github.io

GitHub Pages repository for western-med-bioinfo
https://western-bioinfo.github.io/
1 stars 2 forks source link

LoadError when running `_scripts/fetch-pubmed-xml.rb` #17

Closed ArtPoon closed 1 year ago

ArtPoon commented 1 year ago

On my Mac at home:

art@Wernstrom western-bioinfo.github.io % ruby _scripts/fetch-pubmed-xml.rb 
<internal:/Users/art/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- rest-client (LoadError)
    from <internal:/Users/art/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from _scripts/fetch-pubmed-xml.rb:1:in `<main>'

My Mac was still running system Ruby, but I had rbenv installed (probably via Homebrew) so I went through the installation process described in #11 to set up a local virtual environment with Ruby 3.0.0:

art@Wernstrom western-bioinfo.github.io % rbenv install 3.0.0
To follow progress, use 'tail -f /var/folders/56/3y9v479n0g55nm_b_51dvv_m0000gn/T/ruby-build.20230925181654.23088.log' or pass --verbose
...
Installed ruby-3.0.0 to /Users/art/.rbenv/versions/3.0.0

NOTE: to activate this Ruby version as the new default, run: rbenv global 3.0.0
art@Wernstrom western-bioinfo.github.io % rbenv local 3.0.0
art@Wernstrom western-bioinfo.github.io % export PATH="$HOME/.rbenv/shims:$PATH"
art@Wernstrom western-bioinfo.github.io % which ruby
/Users/art/.rbenv/shims/ruby
art@Wernstrom western-bioinfo.github.io % ruby --version
ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin22]
art@Wernstrom western-bioinfo.github.io % which gem
/Users/art/.rbenv/shims/gem
art@Wernstrom western-bioinfo.github.io % gem install bundler:2.3.4
Fetching bundler-2.3.4.gem
Successfully installed bundler-2.3.4
Parsing documentation for bundler-2.3.4
Installing ri documentation for bundler-2.3.4
Done installing documentation for bundler after 0 seconds
1 gem installed
art@Wernstrom western-bioinfo.github.io % bundle install
Fetching gem metadata from https://rubygems.org/.........
art@Wernstrom western-bioinfo.github.io % gem install rest-client
...
Done installing documentation for netrc, mime-types-data, mime-types, unf_ext, unf, domain_name, http-cookie, http-accept, rest-client after 7 seconds
9 gems installed

This resolved the rest-client LoadError but another exception is thrown:

art@Wernstrom western-bioinfo.github.io % ruby _scripts/fetch-pubmed-xml.rb
<internal:/Users/art/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- nokogiri (LoadError)
    from <internal:/Users/art/.rbenv/versions/3.0.0/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
    from _scripts/fetch-pubmed-xml.rb:2:in `<main>'

This resolved the problem:

art@Wernstrom western-bioinfo.github.io % gem install nokogiri
Fetching nokogiri-1.15.4-x86_64-darwin.gem
Successfully installed nokogiri-1.15.4-x86_64-darwin
Parsing documentation for nokogiri-1.15.4-x86_64-darwin
Installing ri documentation for nokogiri-1.15.4-x86_64-darwin
Done installing documentation for nokogiri after 1 seconds
1 gem installed
art@Wernstrom western-bioinfo.github.io % ruby _scripts/fetch-pubmed-xml.rb

Note this writes XML to both the console and assets/pubmed_result.xml