I am new in shopfy development. I follow the instruction for shopify theme customization – https://shopify.dev/docs/themes/getting-started/customize
When I run shopify theme dev
then an error happens in terminal.
osama@debian:~/works/shopify-dev/OsamaTheme$ shopify theme dev
Error: Command failed with exit code 23: bundle install
There was an error while trying to write to `/usr/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby/Gemfile.lock`. It is likely that you need
to grant write permissions for that path.
Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 12.3.3
When I run shopify theme dev
it should open a preview mode.
My environment details-
THEME CONFIGURATION
Store <STORE_NAME>.myshopify.com
Development Theme ID #1.........8
TOOLING AND SYSTEM
Shopify CLI 3.44.1
OS linux-amd64
Shell /bin/bash
Node version v19.8.1
Ruby version 3.0.0
2
Answers
try with sudo or change permission with
sudo chown -R
. I had similar problem and I am using debian system – sudo helpedsudo shopify theme dev --store
I had this problem too and, after reading Bundler troubleshooting docs, I found out the problem was I had some Bundler versions installed from Gems as regular user. Hopefully (I didn’t check before solving),
bundle install
was using one of them.My solution was to uninstall all Bundler gems, leaving only the OS provided one
After this, running
bundle install
asked for my password and successfully installed all gems thrusudo
:Do not run Bundler with
sudo
Bundler does some actions as root, and some others as regular user. It asks for your sudoer password (if you’re a sudoer) to run root actions as root. If you do
sudo bundle install
, it does all actions as root, including network ones. This is a obvious vunlerability. Besides, it creates root-owned files where they shouldn’t, making you unable to do further actions as a regular user. So follow advice from Bundler man page: "You should never use sudo bundle install".Do not change system directory permissions
They’re there for a reason. Opening them means creating vulnerable spots no one should want. So we better leave them as they are and solve point issues where they are.