ERROR: While executing gem ... (Gem::UnknownCommandError)

Hey there.

Here’s my environment:

I’m also unsure what they new by adding Jekyll as a dependency. The command does not work, am I supposed to copy and paste this to the text file? I don’t think that’s the case, either. See here: CleanShot 2023-05-05 at 21.19.03 · CleanShot Cloud

Any help is appreciated!

I think you may have ruby installed more than once and jekyll is installed in one place but not the other? try uninstalling and reinstalling ruby.

What OS are you on? Macs seem to come with a system Ruby install and then people seem to install it again and then have trouble.

Its usually better to paste the terminal output into a code block here - makes it easier to copy and paste parts of it back into a post as well as googleing something.

I think you may have ruby installed more than once and jekyll is installed in one place but not the other?

That’s probably exactly right! I am on Mac M1, Ventura 13.3, and I had to install ruby through homebrew for the ARM architecture.

What OS are you on? Macs seem to come with a system Ruby install and then people seem to install it again and then have trouble.

Yes, I had to install ruby again because my Mac uses Apple Silicon. I used instructions from here.

Hey @rdyar,

What are the recommended next steps to solve this issue?

Thanks,

did you uninstall ruby and re-install it?

Yes.

==> Fetching ruby
==> Downloading https://ghcr.io/v2/homebrew/core/ruby/manifests/3.2.2
Already downloaded: /Users/kamilszafraniak/Library/Caches/Homebrew/downloads/31caabdd4b3ca900e99c4f3c40dd7c5b20dadbe81e304b2a36aa1da3ce469b49--ruby-3.2.2.bottle_manifest.json
==> Downloading https://ghcr.io/v2/homebrew/core/ruby/blobs/sha256:a4ac080688e871def04469fa335a13de
Already downloaded: /Users/kamilszafraniak/Library/Caches/Homebrew/downloads/f82297ac20f4c71329e4fff612d6aed4b651060e2c5462a78faa6e4239c4dac3--ruby--3.2.2.ventura.bottle.tar.gz
==> Pouring ruby--3.2.2.ventura.bottle.tar.gz
==> Caveats
ruby is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have ruby first in your PATH, run:
 echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc

For compilers to find ruby you may need to set:
 export LDFLAGS="-L/usr/local/opt/ruby/lib"
 export CPPFLAGS="-I/usr/local/opt/ruby/include"

For pkg-config to find ruby you may need to set:
 export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
==> Summary
🍺  /usr/local/Cellar/ruby/3.2.2: 16,605 files, 46.3MB
==> Running `brew cleanup ruby`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
kamilszafraniak@Kamils-Air ~ %   echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
kamilszafraniak@Kamils-Air ~ %   echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc
kamilszafraniak@Kamils-Air ~ % pwd
/Users/kamilszafraniak
kamilszafraniak@Kamils-Air ~ % gem "jekyll"
ERROR:  While executing gem ... (Gem::UnknownCommandError)
   Unknown command jekyll
   /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:205:in `find_command'
   /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:250:in `invoke_command'
   /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:192:in `process_args'
   /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:150:in `run'
   /usr/local/lib/ruby/site_ruby/3.2.0/rubygems/gem_runner.rb:51:in `run'
   /usr/local/opt/ruby/bin/gem:10:in `<main>'
kamilszafraniak@Kamils-Air ~ %

The same issue occurs.
I’m not sure the echo command worked. The output mentioned it might fix the issue.

did you install jekyll?

I have now, but the outcome stays the same.

kamilszafraniak@Kamils-Air ~ % gem install jekyll bundler

Successfully installed jekyll-4.3.2
Parsing documentation for jekyll-4.3.2
Done installing documentation for jekyll after 1 seconds
Fetching bundler-2.4.12.gem
Successfully installed bundler-2.4.12
Parsing documentation for bundler-2.4.12
Installing ri documentation for bundler-2.4.12
Done installing documentation for bundler after 0 seconds
2 gems installed
kamilszafraniak@Kamils-Air ~ % bundle init

Gemfile already exists at /Users/kamilszafraniak/Gemfile
kamilszafraniak@Kamils-Air ~ % gem "jekyll"

ERROR:  While executing gem ... (Gem::UnknownCommandError)
    Unknown command jekyll
	/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:205:in `find_command'
	/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:250:in `invoke_command'
	/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:192:in `process_args'
	/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/command_manager.rb:150:in `run'
	/usr/local/lib/ruby/site_ruby/3.2.0/rubygems/gem_runner.rb:51:in `run'
	/usr/local/opt/ruby/bin/gem:10:in `<main>'

Edit: Tried re-creating the file via bundle init, but did not help.

not sure what that would do as a command? is that a known ruby command? what about jekyll -v to show the version? same thing?

1 Like

Yeah, it’s all solved now. Thanks!