Today I decided to solve a forem (the open-source platform that powers dev.to) bug and had to install it locally.
For Empowering Community
Welcome to the Forem codebase, the platform that powers dev.to. We are so excited to have you. With your help, we can build out Forem’s usability, scalability, and stability to better serve our communities.
What is Forem?
Forem is open source software for building communities. Communities for your peers, customers, fanbases, families, friends, and any other time and space where people need to come together to be part of a collective See our announcement post for a high-level overview of what Forem is.
dev.to (or just DEV) is hosted by Forem. It is a community of software developers who write articles, take part in discussions, and build their professional profiles. We value supportive and constructive dialogue in the pursuit of great code and career growth for all members. The ecosystem spans from beginner to advanced developers, and all are welcome to find their place…
However, I've troubled into this Ruby error when trying to run
gem install bundler after installing rbenv on Mac.
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
This happens because Ruby is trying to use its Mac system version, which is the reason why the forem's installation guide recommends using
rbenv in the first place.
The solution that worked for me was adding
rbenv path to my shell.
With the following commands you'll be able to do the same, auto initialize
rbenv when loading your shell and refreshing it so you don't have to close and open it again.
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc echo 'eval "$(rbenv init -)"' >> ~/.zshrc source ~/.zshrc
If you're not using oh-my-zsh, replace
.bashrc, for example.
That should be enough, but if you're still having problems, try changing the global ruby version on
rbenv and rehash it by running:
rbenv install <version> rbenv global <version> rbenv rehash
Also, quoted from Forem Mac Instructions:
Note: If you are using a Mac with an M1 CPU that uses Ruby compiled for ARM, you may need to force the platform that Bundler uses to ruby. This will allow you to build the C extensions used by Forem's dependencies. To force the platform to use ruby, you can either:
- set `BUNDLE_FORCE_RUBY_PLATFORM=true` in the shell environment - run `bundle config set force_ruby_platform true` to set `ruby` in Bundler globally
gem install bundler should be working!
Hope it helps someone in the future!