Error: 命令以退出代码 23 失败:bundle install

huangapple go评论57阅读模式
英文:

Error: Command failed with exit code 23: bundle install

问题

当我运行shopify theme dev时,终端出现错误。

错误消息如下:

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

当我运行shopify theme dev时,它应该打开预览模式。

我的环境详细信息-

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
英文:

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

答案1

得分: 1

尝试使用sudo或使用sudo chown -R更改权限。我遇到了类似的问题,我正在使用Debian系统 - 使用sudo有所帮助:sudo shopify theme dev --store

英文:

try with sudo or change permission with sudo chown -R. I had similar problem and I am using debian system - sudo helped sudo shopify theme dev --store

答案2

得分: 1

我也遇到了这个问题,阅读了Bundler故障排除文档后,我发现问题是我以常规用户身份从Gems安装了一些Bundler版本。希望(在解决之前我没有检查),bundle install正在使用其中一个。

#这不会告诉每个包是作为根用户还是常规用户安装的
gem list bundler
bundler(2.4.10,2.4.7,2.3.26,2.3.5,默认:2.2.22)

dpkg -l bundler
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Nome           Versão       Arquitectura Descriç&#227ço
+++-==============-============-============-====================================
ii  bundler        2.3.5-2      all          Manage Ruby application dependencies

我的解决方法是卸载所有Bundler宝石,只保留操作系统提供的宝石

sudo gem uninstall bundler
Select gem to uninstall:
 ...
 4. All versions
> 4

之后,运行bundle install会要求输入密码,并成功通过sudo安装所有宝石:

bundle install
Your user account isn't allowed to install to the system RubyGems.
  ...enter your password and install the bundled gems to RubyGems using sudo.
  Password:       
...
Bundle complete! 13 Gemfile dependencies, 173 gems now installed.

不要使用sudo运行Bundler

Bundler以根用户和常规用户的身份执行一些操作。如果您是sudo用户,它会要求您输入sudo密码以根用户身份运行根操作。如果您运行sudo bundle install,它会以根用户的身份执行所有操作,包括网络操作。这是一个明显的漏洞。此外,它会在不应该的地方创建根用户拥有的文件,使您无法以常规用户的身份执行进一步操作。因此,请遵循Bundler手册中的建议:"您不应该使用sudo bundle install"。

不要更改系统目录权限

它们存在有其原因。打开它们意味着创建了任何人都不应该想要的脆弱点。因此,最好将它们保持不变,并在出现问题的地方解决问题。

英文:

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.

# This doesn't tell whether each package is installed as root or regular user
gem list bundler
bundler (2.4.10, 2.4.7, 2.3.26, 2.3.5, default: 2.2.22)

dpkg -l bundler
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Nome           Versão       Arquitectura Descrição
+++-==============-============-============-====================================
ii  bundler        2.3.5-2      all          Manage Ruby application dependencies

My solution was to uninstall all Bundler gems, leaving only the OS provided one

sudo gem uninstall bundler
Select gem to uninstall:
 ...
 4. All versions
> 4

After this, running bundle install asked for my password and successfully installed all gems thru sudo:

bundle install
Your user account isn't allowed to install to the system RubyGems.
  ...enter your password and install the bundled gems to RubyGems using sudo.
  Password:       
...
Bundle complete! 13 Gemfile dependencies, 173 gems now installed.

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.

huangapple
  • 本文由 发表于 2023年4月4日 18:20:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75928210.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定