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

**URL:** <https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220>\
**Category:** Help\
**Created:** [May 5, 2023, 7:18pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220 "2023-05-05T19:18:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![szfkamil](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@szfkamil](https://talk.jekyllrb.com/u/szfkamil)\
**Post date:** [May 5, 2023, 7:18pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/1 "2023-05-05T19:18:44Z")

</div>

Hey there.

Here’s my environment:

 ![CleanShot 2023-05-05 at 21.18.14@2x](https://canada1.discourse-cdn.com/flex030/uploads/jekyllrb/original/2X/1/1213734b3deaf546fa7ef69c34a32eb0ab227c7c.jpeg)

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](https://share.cleanshot.com/TtwQX4F1)

Any help is appreciated!

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [May 6, 2023, 4:29pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/2 "2023-05-06T16:29:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![szfkamil](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@szfkamil](https://talk.jekyllrb.com/u/szfkamil)\
**Post date:** [May 6, 2023, 5:53pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/3 "2023-05-06T17:53:15Z")

</div>

> 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](https://stackoverflow.com/questions/51126403/you-dont-have-write-permissions-for-the-library-ruby-gems-2-3-0-directory-ma).

---

<div class="post-metadata">

**Author:** ![szfkamil](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@szfkamil](https://talk.jekyllrb.com/u/szfkamil)\
**Post date:** [May 9, 2023, 3:41pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/4 "2023-05-09T15:41:19Z")

</div>

Hey @rdyar,

What are the recommended next steps to solve this issue?

Thanks,

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [May 9, 2023, 4:06pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/5 "2023-05-09T16:06:31Z")

</div>

did you uninstall ruby and re-install it?

---

<div class="post-metadata">

**Author:** ![szfkamil](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@szfkamil](https://talk.jekyllrb.com/u/szfkamil)\
**Post date:** [May 9, 2023, 6:46pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/6 "2023-05-09T18:46:33Z")

</div>

Yes.

```auto
==> 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.

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [May 9, 2023, 7:32pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/7 "2023-05-09T19:32:05Z")

</div>

did you install jekyll?

---

<div class="post-metadata">

**Author:** ![szfkamil](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@szfkamil](https://talk.jekyllrb.com/u/szfkamil)\
**Post date:** [May 9, 2023, 9:39pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/8 "2023-05-09T21:39:06Z")

</div>

I have now, but the outcome stays the same.

```auto
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.

---

<div class="post-metadata">

**Author:** ![rdyar](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.jekyllrb.com/rdyar/32/710_2.png) [@rdyar](https://talk.jekyllrb.com/u/rdyar)\
**Post date:** [May 9, 2023, 9:46pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/9 "2023-05-09T21:46:01Z")

</div>

> [@szfkamil](#):
>
> `gem "jekyll"`

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?

---

<div class="post-metadata">

**Author:** ![szfkamil](https://avatars.discourse-cdn.com/v4/letter/s/3d9bf3/32.png) [@szfkamil](https://talk.jekyllrb.com/u/szfkamil)\
**Post date:** [May 29, 2023, 1:06pm UTC](https://talk.jekyllrb.com/t/error-while-executing-gem-gem-unknowncommanderror/8220/10 "2023-05-29T13:06:00Z")

</div>

Yeah, it’s all solved now. Thanks!
