简体   繁体   English

自制软件:安装时缺少权限

[英]Homebrew: lack permissions when installing

I'm trying to write my first formula, for the Rserve package in R: https://www.rforge.net/Rserve/ . 我正在尝试为R中的Rserve包编写第一个公式: https : Rserve

So far I have this: 到目前为止,我有这个:

# Documentation: https://docs.brew.sh/Formula-Cookbook
#                https://www.rubydoc.info/github/Homebrew/brew/master/Formula
class Rserve < Formula
  desc "Rserve acts as a socket server (TCP/IP or local sockets) which allows binary requests to be sent to R."
  homepage "http://www.rforge.net/Rserve/"
  url "https://cran.r-project.org/src/contrib/Rserve_1.7-3.tar.gz"
  sha256 "f6d636c736c3f16487d9987e54554fe0c55257b9bc0671b43e536d832e513027"

  depends_on "r"
  depends_on "gettext"

  def install
    system("whoami")
    system("#{HOMEBREW_PREFIX}/bin/R CMD install --configure-args=\"CPPFLAGS=-L#{HOMEBREW_PREFIX}/opt/gettext/lib LDFLAGS=-I#{HOMEBREW_PREFIX}/opt/gettext/include\" .")
  end

  test do
    # `test do` will create, run in and delete a temporary directory.
    #
    # This test will fail and we won't accept that! For Homebrew/homebrew-core
    # this will need to be a test that verifies the functionality of the
    # software. Run the test with `brew test Rserve`. Options passed
    # to `brew install` such as `--HEAD` also need to be provided to `brew test`.
    #
    # The installed folder is not in the path, so use the entire path to any
    # executables being tested: `system "#{bin}/program", "do", "something"`.
    system "false"
  end
end

The error I get is: 我得到的错误是:

==> Downloading https://cran.r-project.org/src/contrib/Rserve_1.7-3.tar.gz
Already downloaded: /Users/kwilliams/Library/Caches/Homebrew/downloads/690e0934dcba3770ba80b743f7b2c9cee0250434ed17cc7949bc1eee74d5b170--Rserve_1.7-3.tar.gz
==> Verifying 690e0934dcba3770ba80b743f7b2c9cee0250434ed17cc7949bc1eee74d5b170--Rserve_1.7-3.tar.gz checksum
tar xf /Users/kwilliams/Library/Caches/Homebrew/downloads/690e0934dcba3770ba80b743f7b2c9cee0250434ed17cc7949bc1eee74d5b170--Rserve_1.7-3.tar.gz -C /private/tmp/d20190114-99089-11isfza
cp -pR /private/tmp/d20190114-99089-11isfza/Rserve/. /private/tmp/rserve-20190114-99089-b57ji6/Rserve
chmod -Rf +w /private/tmp/d20190114-99089-11isfza
==> whoami
kwilliams
==> /usr/local/bin/R CMD install --configure-args="CPPFLAGS=-L/usr/local/opt/gettext/lib LDFLAGS=-I/usr/local/opt/gettext/include" .
* installing to library ‘/usr/local/lib/R/3.5/site-library’
Error: ERROR: no permission to install to directory ‘/usr/local/lib/R/3.5/site-library’

==> Formula
Path: /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core/Formula/rserve.rb
==> Configuration
HOMEBREW_VERSION: 1.9.2-5-g44f4f36
ORIGIN: https://github.com/Homebrew/brew
HEAD: 44f4f36c0db693000410fe664b250a90325f4e32
Last commit: 4 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: de1ecc1d981de9d5165ea9e96242c32023d14d7c
Core tap last commit: 4 hours ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DEV_CMD_RUN: 1
HOMEBREW_ENABLE_AUTO_UPDATE_MIGRATION: 1
HOMEBREW_LOGS: /Users/kwilliams/Library/Logs/Homebrew
CPU: octa-core 64-bit kabylake
Homebrew Ruby: 2.3.7 => /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
Clang: 10.0 build 1000
Git: 2.17.2 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 7.54.0 => /usr/bin/curl
Java: 11.0.1, 1.8.0_192
macOS: 10.13.6-x86_64
CLT: 10.1.0.0.1.1539992718
Xcode: 10.1
XQuartz: 2.7.11 => /opt/X11

The permissions on /usr/local/lib/R/3.5/site-library should allow me to install there, though: 我可以在/usr/local/lib/R/3.5/site-library进行安装,但是:

% ls -al /usr/local/lib/R/3.5/site-library
total 0
drwxr-xr-x  2 kwilliams  admin  64 Jan 14 13:38 ./
drwxr-xr-x  3 kwilliams  admin  96 Jan 14 13:38 ../

If I put myself in a directory where the Rserve tarball has been freshly expanded, then manually run the command /usr/local/bin/R CMD install --configure-args="CPPFLAGS=-L/usr/local/opt/gettext/lib LDFLAGS=-I/usr/local/opt/gettext/include" . 如果我将自己放在Rserve压缩文件的新目录中,请手动运行命令/usr/local/bin/R CMD install --configure-args="CPPFLAGS=-L/usr/local/opt/gettext/lib LDFLAGS=-I/usr/local/opt/gettext/include" . , I don't get the error about "no permission to install to directory". ,我没有收到关于“无权安装到目录”的错误。

What's different about the environment that Homebrew is running that command, compared to me running it in a shell, that causes it to fail when run automatically? 与我在shell中运行该命令相比,Homebrew在运行该命令的环境有什么不同,导致它在自动运行时失败?

My brew doctor output is clean, except for a warning that my docker keg is unlinked, which I assume is unrelated. 我的brew doctor输出是干净的,除了警告我的docker桶未链接(我认为这无关)。

Figured it out - there's a sandbox ( sandbox-exec , I think) in place that restricts writing to the filesystem outside the prefix directory: 弄清楚了-有一个沙箱(我认为是sandbox-exec )限制了对前缀目录外部文件系统的写入:

https://discourse.brew.sh/t/potential-permission-issues-in-a-formula-im-writing/3707 https://discourse.brew.sh/t/potential-permission-issues-in-a-formula-im-writing/3707

I'll need to figure out the correct way to write files to /usr/local/lib/R/3.5/site-library , or symlink them to there from the Cellar directory, or whatever it is. 我需要找出将文件写入/usr/local/lib/R/3.5/site-library的正确方法,或者从Cellar目录或任何目录将它们符号链接到那里。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM