Installing Jekyll on Ubuntu 22.04

I am trying to install jekyll. But I am getting this error:

$ gem install jekyll bundler
ERROR:  Could not find a valid gem 'jekyll' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Gem::Net::OpenTimeout: Failed to open TCP connection to rubygems.org:443 (execution expired) (https://rubygems.org/specs.4.8.gz)
ERROR:  Could not find a valid gem 'bundler' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Gem::Net::OpenTimeout: Failed to open TCP connection to rubygems.org:443 (execution expired) (https://rubygems.org/specs.4.8.gz)

It should be noted that I have tried multiple times, my internet connection seems ok and the server is also not down. Why is it occurring? How can I fix this issue?

Moreover, I have tested with another gem too, facing the same error:

$ gem install rake
ERROR:  Could not find a valid gem 'rake' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - Gem::Net::OpenTimeout: Failed to open TCP connection to rubygems.org:443 (execution expired) (https://rubygems.org/specs.4.8.gz)
ERROR:  Possible alternatives: DotCoverRakeTask, airake, airbrake, airbrake-api, airbrake-extended, airbrake-faraday_sender, airbrake-jets, airbrake-local, airbrake-resque, airbrake-ruby

Here are the installed prerequisites (Jekyll on Ubuntu | Jekyll • Simple, blog-aware, static sites):

$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-linux-gnu]

$ gem -v
3.5.14

$ gem update --system
ERROR:  Your RubyGems was installed trough APT, and upgrading it through RubyGems
itself is unsupported. If you really need the latest version of RubyGems (tip:
you usually don't), then you need to install RubyGems (and Ruby) manually,
maybe using tools like ruby-install, rvm, etc.

$ gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.5.14
  - RUBY VERSION: 3.0.2 (2021-07-07 patchlevel 107) [x86_64-linux-gnu]
  - INSTALLATION DIRECTORY: /var/lib/gems/3.0.0
  - USER INSTALLATION DIRECTORY: /home/rafi/.local/share/gem/ruby/3.0.0
  - RUBY EXECUTABLE: /usr/bin/ruby3.0
  - GIT EXECUTABLE: /usr/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - SPEC CACHE DIRECTORY: /home/rafi/.cache/gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-linux-gnu
  - GEM PATHS:
     - /var/lib/gems/3.0.0
     - /home/rafi/.local/share/gem/ruby/3.0.0
     - /usr/local/lib/ruby/gems/3.0.0
     - /usr/lib/ruby/gems/3.0.0
     - /usr/lib/x86_64-linux-gnu/ruby/gems/3.0.0
     - /usr/share/rubygems-integration/3.0.0
     - /usr/share/rubygems-integration/all
     - /usr/lib/x86_64-linux-gnu/rubygems-integration/3.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => true
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /home/rafi/.local/bin
     - /home/rafi/bin
     - /usr/local/sbin
     - /usr/local/bin
     - /usr/sbin
     - /usr/bin
     - /sbin
     - /bin
     - /usr/games
     - /usr/local/games
     - /snap/bin
     - /snap/bin
     - /home/rafi/.rvm/bin
$ dpkg -l | grep ruby
ii  libruby3.0:amd64                              3.0.2-7ubuntu2.7                                     amd64        Libraries necessary to run Ruby 3.0
ii  rake                                          13.0.6-2                                             all          ruby make-like utility
ii  ruby                                          1:3.0~exp1                                           amd64        Interpreter of object-oriented scripting language Ruby (default version)
ii  ruby-dev:amd64                                1:3.0~exp1                                           amd64        Header files for compiling extension modules for Ruby (default version)
ii  ruby-full                                     1:3.0~exp1                                           all          Ruby full installation (default version)
ii  ruby-net-telnet                               0.1.1-2                                              all          telnet client library
ii  ruby-rubygems                                 3.3.5-2                                              all          Package management framework for Ruby
ii  ruby-webrick                                  1.7.0-3                                              all          HTTP server toolkit in Ruby
ii  ruby-xmlrpc                                   0.3.2-1ubuntu0.1                                     all          XMLRPC library for Ruby
ii  ruby3.0                                       3.0.2-7ubuntu2.7                                     amd64        Interpreter of object-oriented scripting language Ruby
ii  ruby3.0-dev:amd64                             3.0.2-7ubuntu2.7                                     amd64        Header files for compiling extension modules for the Ruby 3.0
ii  ruby3.0-doc                                   3.0.2-7ubuntu2.7                                     all          Documentation for Ruby 3.0
ii  rubygems-integration                          1.18                                                 all          integration of Debian Ruby packages with Rubygems

Update

It was set warp-cli connect for the package cloudflare-warp. After switching it to warp-cli disconnect, the errors don’t appear for the command:

 sudo gem install jekyll bundler

Why was it happening with warp-cli connect? How can I use gem install keeping warp-cli connect? Do I need set a specific configuration for warp-cli?

And without sudo, it says this:

$ gem install jekyll bundler
Defaulting to user installation because default installation directory (/var/lib/gems/3.0.0) is not writable.
Successfully installed jekyll-4.3.3
Parsing documentation for jekyll-4.3.3
Done installing documentation for jekyll after 0 seconds
Defaulting to user installation because default installation directory (/var/lib/gems/3.0.0) is not writable.
Successfully installed bundler-2.5.14
Parsing documentation for bundler-2.5.14
Done installing documentation for bundler after 0 seconds
2 gems installed

Another error that is still appearing:

$ sudo gem update --system
ERROR:  Your RubyGems was installed trough APT, and upgrading it through RubyGems
itself is unsupported. If you really need the latest version of RubyGems (tip:
you usually don't), then you need to install RubyGems (and Ruby) manually,
maybe using tools like ruby-install, rvm, etc.

How can I fix it?

where are you located? I see a few other issues with that error, they say they were in a country that blocked rubygems. org

can you browse that site ok? https://rubygems.org/

Kindly check the update on my question.

It is shared on Jekyll on Ubuntu 22.04 - Ask Ubuntu and Jekyll installation error on Ubuntu 22.04 · jekyll/jekyll · Discussion #9628 · GitHub too.

Hi There,

It looks like you replied to an answer a few times, removed those replies, and then updated your original post. That will not work moving forward. Always respond to the person who attempted to answer the questions and only update your post for grammatical errors or basic modifications; otherwise, we cannot follow along. I happen to be coming into this post blind because @rdyar pointed out an issue with Ubuntu in other countries which I was completely unaware of. If I am saying any of this in error, my apologies.

I am unfamiliar with Warp-CLI, so I started asking ChatGPT about it and learned that you are probably encountering issues related to how you are using Cloudflare and not so much Jekyll or Ubuntu

The following response is AI-generated because after discussing the topic, it looks like it might solve your problem, which I am unfamiliar with. The rest of the stuff, like building Ruby with RVM and installing Jekyll, all seem standard. I do not know if the user installation path issues are necessary, so you might try avoiding them first.


The issues you are encountering stem from a combination of network configuration and the method of RubyGems installation. Let’s address each part systematically.

Network Configuration with Cloudflare Warp

The issue with warp-cli connect causing timeout errors can be due to how Cloudflare Warp handles DNS and network routing. When connected to Warp, your internet traffic is routed through Cloudflare’s network, which might cause connectivity issues with certain services like RubyGems.

To use gem install while keeping warp-cli connect, you can try the following:

  1. Add a Proxy Configuration: Configure gem to use a proxy that can handle the traffic appropriately.

    gem install jekyll bundler --http-proxy http://proxy_address:proxy_port --https-proxy http://proxy_address:proxy_port
    

    Replace proxy_address and proxy_port with the appropriate values for your network.

  2. Adjust Warp Settings: Ensure Warp is not blocking or altering traffic to rubygems.org. You might need to configure exceptions for certain traffic if Warp allows such configurations.

  3. Temporary Disconnect: As a temporary workaround, disconnect Warp while you install the necessary gems and reconnect it afterward.

Installing RubyGems and Ruby Manually

Since the RubyGems installation via APT restricts updating through RubyGems itself, you might consider installing Ruby and RubyGems manually using tools like rvm (Ruby Version Manager). Here’s a step-by-step guide:

  1. Install RVM:

    \curl -sSL https://get.rvm.io | bash -s stable
    
  2. Load RVM:

    source ~/.rvm/scripts/rvm
    
  3. Install Ruby:

    rvm install 3.0.2
    rvm use 3.0.2 --default
    
  4. Verify Installation:

    ruby -v
    gem -v
    
  5. Install Jekyll and Bundler:

    gem install jekyll bundler
    

Fixing User Installation Path

To resolve the permission issue without sudo, ensure your user-specific gem path is properly configured in your .bashrc or .bash_profile:

echo '# Install Ruby Gems to ~/gems' >> ~/.bashrc
echo 'export GEM_HOME="$HOME/gems"' >> ~/.bashrc
echo 'export PATH="$HOME/gems/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

After setting this up, you can install gems without sudo:

gem install jekyll bundler

Summary of Actions

  1. Configure Proxy or Adjust Warp Settings: To work around network issues with Cloudflare Warp.
  2. Install Ruby and RubyGems Manually: Use rvm to avoid the limitations of the APT-installed RubyGems.
  3. Set Up User Gem Path: Ensure user-specific gem installations are configured correctly.

These steps should help you address the connectivity issues and ensure a smooth installation of Jekyll and Bundler. If you have any further issues, feel free to ask!