Installing Jekyll 3.8.5 on GitHub Pages - ruby

Description
I'm trying to setup my personal website using GitHub Pages with Jekyll 3.8.5 as described in https://help.github.com/en/github/working-with-github-pages/creating-a-github-pages-site-with-jekyll, but having an issue with the bundler.
Details
Bundle can't find the installed Jekyll 3.8.5
$ bundle exec jekyll 3.8.5 new .
fatal: 'jekyll 3.8.5' could not be found. You may need to install the jekyll-3.8.5 gem or a related gem to be able to use this subcommand.`
Verifying that I actually have jekyll-3.8.5
$ bundle info jekyll
* jekyll (3.8.5)
Summary: A simple, blog aware, static site generator.
Homepage: https://github.com/jekyll/jekyll
Path: /Users/macikportali/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/jekyll-3.8.5
Gemfile (installed with bundle install)
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
# gem "jekyll", "~> 4.0.0"
# gem "jekyll", "~> 3.8.5"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.5"
gem "jekyll-athena"
# Seems this is needed to install a lot of subcommands, see: https://github.com/jekyll/jekyll-compose
gem 'jekyll-compose', group: [:jekyll_plugins]
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# for jekyll 3.8.5
gem "github-pages", "204", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.11"
end
# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
gem "tzinfo", "~> 1.2"
gem "tzinfo-data"
end
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?
Jekyll is used with shims
$ which jekyll
/Users/macikportali/.rbenv/shims/jekyll
My current rbenv version
$ rbenv version
2.7.1 (set by /Users/macikportali/.rbenv/version)
Question
Why bundler cannot see the installed jekyll-3.8.5 gem?

Okey, I think I figured it out. I have two different versions for Jekyll.
$ gem list jekyll
*** LOCAL GEMS ***
jekyll (4.0.1, 3.8.5)
What I did was to add underscores(_) as prefix and postfix to the version, thus, executed
bundle exec jekyll _3.8.5_ new docs
That fixed the problem because I believe this is the convention that gem follows when you have different versions.
Now, I have a different problem which is having 404 page but that's another issue to deal with.

Related

Could not find a custom installed gem during runtime

On rhel8, I built and installed a custom gem test1.
$ gem build test1.gemspec
Successfully built RubyGem
Name: test1
Version: 0.0.1
File: test1-0.0.1.gem
$ gem install test1-0.0.1.gem
Successfully installed test1-0.0.1
1 gem installed
# check if gem is installed. All gems are installed in this path
$ gem which test1
/usr/local/share/gems/gems/test1-0.0.1/lib/test1.rb
Now in another custom gem I build, the gemspec file looks like this:
# in test2.gemspec file
Gem::Specification.new do |spec|
spec.name = "test2"
...
spec.add_runtime_dependency "test1", "0.0.1"
...
end
When I try to go install test2 gem it fails and says it could not find the test1 gem which is already installed. This problem started happening on rhel8. I tested on debian and alpine and it had no issues finding and installing the gem.
$ gem build test2.gemspec
Successfully built RubyGem
Name: test2
Version: 0.0.1
File: test2-0.0.1.gem
$ gem install test2-0.0.1.gem
ERROR: Could not find a valid gem 'test1' (= 0.0.1) in any repository
If I change to add_development_dependency, it builds and installs the gem. The image works as expected and has no issues. Does anyone know why its not able to find the gem when I add add_runtime_dependency?
If you are building a private gem that requires another private gem, you will need to define the dependency gem in both the gemspec and the Gemfile, while providing the actual source in the Gemfile.
For example, we are using GemFury to host private gems, and then in any other gem that needs this private gem, we do this:
# Gemfile
source 'https://gem.fury.io/your-user/' do
gem 'your-gem'
end
gemspec
# your-gem.gemspec
s.add_runtime_dependency 'your-gem', '0.0.1'

What is the format for the dependency version to install github pages and jekyll?

I was following the github instructions for jekyll and github. At step 8 & 9 it says:
8) Open the Gemfile that was created and follow the instructions in the
Gemfile's comments to use GitHub Pages.
# uncomment the line below. To upgrade, run `bundle update github-pages`.
gem "github-pages", group: :jekyll_plugins
9) Update the gem "github-pages" line so that the line looks like this, replacing VERSION with the current dependency version for
github-pages. For more information, see "Dependency versions" on the
GitHub Pages site.
gem "github-pages", "~> VERSION", group: :jekyll_plugins
but I don't understand what goes in VERSION
I tried the following:
# gem "github-pages", "~> jekyll 3.8.5", group: :jekyll_plugins
#gem "github-pages", "~> 3.8.5", group: :jekyll_plugins
but they all result in errors. However, its obvious that the errors don't matter because I don't know what is suppose to go in Version. Whats supposed to go in version VERSION?
related error:
https://talk.jekyllrb.com/t/how-to-install-github-pages-with-jekyll/3510
The versions for the github-pages gem are different than for the Jekyll gem.
To look up a gem's versions, use RubyGems.org.
Here are the versions for github-pages: https://rubygems.org/gems/github-pages
The latest version is 202, so you'd put:
gem "github-pages", "202"
With each new release (you can watch the github/pages-gem repo for releases if you want to be notified when new ones are released), just replace the "202" with the new version in quotes.
Hope this helps.

Ruby - Cannot use locally installed gem

I've written a simple PasswordGenerator gem that I have at ~/workspace/gems/password_generator and have an app at ~/workspace/rubysamples/app where I want to use it. I have a Gemfile, the content of it is this:
gem 'password_generator', path: '~/workspace/gems/password_generator'
I installed it locally, like this:
bundle install --local
Resolving dependencies...
Using bundler 1.16.5
Using password_generator 0.1.0 from source at `~/workspace/gems/password_generator`
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
It looks like it's installed locally:
bundle info password_generator
* password_generator (0.1.0)
Summary: Simple password generator
Homepage: https://github.com/jedrekdomanski/password_generator
Path: /home/jedrek/workspace/gems/password_generator
When I try to use it
~/workspace/rubysamples/app/password_reset.rb
PasswordGenerator.generate
I get an error
uninitialized constant PasswordGenerator (NameError)
What am I doing wrong? Am I missing anything?
Here's my gem repo: https://github.com/jedrekdomanski/password_generator
I also tried pointing to my repo and branch in the Gemfile
gem 'password_generator', git: 'git#github.com:jedrekdomanski/password_generator.git', branch: 'master'
but I get the same error message uninitialized constant PasswordGenerator (NameError)
There are potentially two issues. The first is how you are starting Ruby and the second is how you are requiring your module.
First, if you are starting Ruby by running ruby password_reset.rb then you are ignoring the Gemfile. The Gemfile is only used when you're using bundler, so you want to make sure you are starting Ruby by running bundle exec ruby password_reset.rb. This causes bundler to read your Gemfile and execute Ruby in that context.
Second, you're not properly including your module in your Ruby file. Just because you've added the gem to your Gemfile and started Ruby using bundler doesn't mean that the Ruby process knows you intend to use that gem's module; it just makes the module available for use. You might wonder, "Why don't I have to do that in Rails?" Because Rails does that for you automatically via config/application.rb.
Given these two issues, the correct way to accomplish your goal is to configure your app as follows:
First, create your Gemfile:
# Gemfile
gem 'password_generator', path: '~/workspace/gems/password_generator'
Second, create your password_reset.rb file:
# password_reset.rb
# Manually require any libraries that this app will use, even if defined in Gemfile
require 'password_generator'
# Call `puts` so something is printed to the console when this app runs
puts PasswordGenerator.generate
Third, run bundle install to ensure your Gemfile is properly formatted and to generate your Gemfile.lock:
⇒ bundle install
Using bundler 1.16.5
Using password_generator 0.1.0 from source at `../../gems/password_generator`
Bundle complete! 1 Gemfile dependency, 2 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Fourth, run bundle exec ruby password_reset.rb and observe the output:
⇒ bundle exec ruby password_reset.rb
kpiDfyTxtdAsKmYuZqmK
Everything works because:
Ruby is started with Bundler
Bundler reads your Gemfile and makes the gems available to Ruby
Your app requires the module from the gem before attempting to use the module

Rubymotion, adding interface builder: running a rake task from gem gives "Don't know how to build task 'ib'"

I have a Ruby Motion project, and I want to add Interface Builder to it.
I've added the gem:
gem 'ib'
But when I run bundle exec rake ib, I get Don't know how to build task 'ib'
Does any one know what I might be doing wrong? here is my gemfile:
source "https://rubygems.org"
gem "rake"
gem "ProMotion", '~> 2.0'
gem "ProMotion-push", git: 'git#github.com:BananaNeil/ProMotion-push.git', :branch => 'actionable-push-notifications'
gem "cocoapods"
gem "motion-cocoapods"
gem 'xcodeproj'
gem "bubble-wrap-http", git: 'git#github.com:BananaNeil/BubbleWrap-HTTP.git', branch: 'allow_invalid_ssl_certs'
gem "bubble-wrap"
gem "sugarcube" # monkeypatch all the things
gem "motion-yaml"
gem "motion-stump"
gem 'houston'
# Enter debugger with simple syntax
gem 'dbt' #-----> break
# Add pretty print
gem 'motion-pp'
# Handle address book for us
gem 'motion-addressbook'
gem 'ib'
Make sure to require 'ib' inside the Rakefile, either with Bundler or manually for each gem.
And if you use Bundler, you might need to remove the begin/catch guard, because it will silence all import related errors.

Heroku with ruby 1.9.3 causing many different crashes

I go to redeploy my heroku apps with a new gem in Gemfile and it crashes on startup
/app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require': libruby.so.1.9: cannot open shared object file: No such file or directory - /app/vendor/bundle/ruby/1.9.1/gems/bcrypt-ruby-3.0.1/lib/bcrypt_ext.so (LoadError)
This is happening no matter what branch I deploy (old stable ones...) and only fixes by doing a heroku rollback.
I believe this is caused by heroku recently updating their ruby 1.9.3 because I was having this issue Heroku app crashes with 'libruby.so.1.9: cannot open shared object file' . Removing the nokogiri gem stopped the exception I was getting but then there's still this. More similar errors occur when I add new gems.
The whole problem was solved by deploying to a new heroku app but that's not something I can just do on my production server.
Any ideas on fixing the issue or somehow "refreshing" my app?
my gemfile:
source "https://rubygems.org"
ruby "1.9.3"
gem "rails", "3.2.3"
gem "thin"
# Bundle edge Rails instead:
# gem "rails", :git => "git://github.com/rails/rails.git"
gem "mongoid"
gem "devise"
gem "haml"
gem "sass"
gem "exceptional"
gem "kaminari"
gem "mongoid_search"
#gem "nokogiri"
gem "bson_ext"
gem "heroku-mongo-backup"
gem "aws-s3"
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem "haml-rails", "~> 0.3.4"
gem "sass-rails", "~> 3.2.3"
gem "coffee-rails", "~> 3.2.1"
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem "therubyracer", :platform => :ruby
gem "uglifier", ">= 1.0.3"
end
gem "jquery-rails"
group :test do
gem "mongoid-rspec"
end
# To use ActiveModel has_secure_password
# gem "bcrypt-ruby", "~> 3.0.0"
# To use Jbuilder templates for JSON
# gem "jbuilder"
# Use unicorn as the app server
# gem "unicorn"
# Deploy with Capistrano
# gem "capistrano"
# To use debugger
# gem "ruby-debug19", :require => "ruby-debug"
#
group :development do
gem "letter_opener"
end
Just FYI,
After contacting the Heroku support about this issue, you should follow these 3 simple steps:
Install this heroku-repo plugin: heroku plugins:install https://github.com/lstoll/heroku-repo.git
Run the following command: heroku repo:purge_cache
Deploy your app again.
Hope that helps!
This happened to me yesterday as well, was definitely something to do with Heroku.
I found fix and discussion on Twitter: https://twitter.com/bcardarella/status/256822171979100161
Just force-clear the gem file cache(clear gemfile, deploy, restore and deploy) and the app would start smoothly again.

Resources