You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Shopify主题开发执行shopify theme dev报错:bundle install退出码23

解决Shopify CLI执行shopify theme dev时的Gemfile.lock权限错误

问题详情

执行shopify theme dev命令时终端抛出权限错误,无法完成bundle install,导致预览模式无法启动:

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

环境信息:

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

解决方案

1. 直接修改目标目录权限

给cli-ruby目录添加当前用户的写入权限,两种方式选其一:

  • 开放目录读写执行权限(快速解决):
    sudo chmod -R 775 /usr/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby
    
  • 修改目录所有者为当前用户(更安全):
    sudo chown -R $USER:$USER /usr/lib/node_modules/@shopify/theme/node_modules/@shopify/cli-kit/assets/cli-ruby
    

2. 本地安装Shopify CLI(推荐,避免全局权限问题)

全局Node包常引发权限冲突,建议在项目本地安装CLI:

  1. 卸载全局Shopify CLI:
    npm uninstall -g @shopify/cli @shopify/theme
    
  2. 进入项目目录,初始化npm(若未初始化):
    npm init -y
    
  3. 本地安装Shopify CLI依赖:
    npm install @shopify/cli @shopify/theme --save-dev
    
  4. 使用npx执行开发命令:
    npx shopify theme dev
    

3. 配置Ruby版本管理器

全局Ruby环境的权限问题也可能影响bundle操作,通过rbenv或rvm管理本地Ruby版本:

  1. 安装rbenv并配置本地Ruby版本为3.0.0(与当前环境匹配)
  2. 重新执行shopify theme dev命令

验证

完成上述任意操作后,重新运行shopify theme dev,确认命令能正常启动预览模式。

内容的提问来源于stack exchange,提问作者Osama Abdullah

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.26 01:12:24