首先,如果这属于 Ask Ubuntu,我很抱歉...我不太确定它属于哪个论坛。
我正在尝试使用 PHP 和 shell 脚本从 Github fork 并构建一个 Android 项目。基本上,我正在打印我写入网站的 shell 脚本的一些输出。当您访问该页面并按下一些按钮时,该项目将使用 Gradle 进行 fork 和构建。 PHP 代码运行 shell 脚本,然后在命令运行时将输出打印到浏览器。
但是,我的脚本输出了这个错误:
FAILURE: Build failed with an exception.
* What went wrong:
Failed to load native library 'libnative-platform.so' for Linux amd64.
该脚本目前只是运行 gradle build,但我打算稍后更改它...现在,我只是致力于构建根项目并输出结果。
如果我使用 --stacktrace 标志运行命令,这里是输出:
* Exception is:
net.rubygrapefruit.platform.NativeException: Failed to load native library 'libnative-platform.so' for Linux amd64.
at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:49)
at net.rubygrapefruit.platform.Native.init(Native.java:55)
at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:74)
at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:60)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:203)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:622)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
Caused by: java.io.IOException: No such file or directory
at java.io.UnixFileSystem.createFileExclusively(Native Method)
at java.io.File.createNewFile(File.java:959)
at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(NativeLibraryLocator.java:39)
at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:41)
... 16 more
这是带有 --debug 标志的输出:
06:21:43.710 [ERROR] [org.gradle.BuildExceptionReporter]
06:21:43.740 [ERROR] [org.gradle.BuildExceptionReporter] FAILURE: Build failed with an exception.
06:21:43.747 [ERROR] [org.gradle.BuildExceptionReporter]
06:21:43.747 [ERROR] [org.gradle.BuildExceptionReporter] * What went wrong:
06:21:43.748 [ERROR] [org.gradle.BuildExceptionReporter] Failed to load native library 'libnative-platform.so' for Linux amd64.
06:21:43.749 [ERROR] [org.gradle.BuildExceptionReporter]
06:21:43.750 [ERROR] [org.gradle.BuildExceptionReporter] * Exception is:
06:21:43.752 [ERROR] [org.gradle.BuildExceptionReporter] net.rubygrapefruit.platform.NativeException: Failed to load native library 'libnative-platform.so' for Linux amd64.
06:21:43.753 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:49)
06:21:43.753 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.Native.init(Native.java:55)
06:21:43.754 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:74)
06:21:43.754 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.internal.nativeintegration.services.NativeServices.initialize(NativeServices.java:60)
06:21:43.755 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:203)
06:21:43.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
06:21:43.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
06:21:43.756 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
06:21:43.757 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.Main.doAction(Main.java:33)
06:21:43.758 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
06:21:43.759 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
06:21:43.759 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
06:21:43.760 [ERROR] [org.gradle.BuildExceptionReporter] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
06:21:43.760 [ERROR] [org.gradle.BuildExceptionReporter] at java.lang.reflect.Method.invoke(Method.java:622)
06:21:43.761 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
06:21:43.761 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
06:21:43.762 [ERROR] [org.gradle.BuildExceptionReporter] at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
06:21:43.762 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.io.IOException: No such file or directory
06:21:43.763 [ERROR] [org.gradle.BuildExceptionReporter] at java.io.UnixFileSystem.createFileExclusively(Native Method)
06:21:43.763 [ERROR] [org.gradle.BuildExceptionReporter] at java.io.File.createNewFile(File.java:959)
06:21:43.764 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.internal.NativeLibraryLocator.find(NativeLibraryLocator.java:39)
06:21:43.764 [ERROR] [org.gradle.BuildExceptionReporter] at net.rubygrapefruit.platform.internal.NativeLibraryLoader.load(NativeLibraryLoader.java:41)
06:21:43.765 [ERROR] [org.gradle.BuildExceptionReporter] ... 16 more
06:21:43.765 [ERROR] [org.gradle.BuildExceptionReporter]
我对此事做了一些研究,发现 this forum post ,但它没有给我任何解决问题的线索。
进一步的研究使我找到了 Github issue ,它似乎适用于 NixOS,但我正在运行 Ubuntu 12.04 CLI。另外,我应该提到我也在运行 Gradle 2.10。
我也尝试运行 gradle -Dorg.gradle.native=false build,但结果是一样的。
现在,就调用脚本的用户而言,我相信它是 www-data,因为我运行的是 Apache2 网络服务器和 PHP。
这是运行脚本的一小段 PHP 代码,我在另一个 SO post 上找到了它:
<?php
$command = "sh /home/andrew/scripts/build.sh 2>&1";
while (@ ob_end_flush()); // end all output buffers if any
$proc = popen($command, 'r');
echo '<pre style="border-radius: 5px; padding:4px; color:black; background:#ffffff" align="left">';
while (!feof($proc)){
echo fread($proc, 1024);
@ flush();
}
echo '</pre>';
?>
我现在不知所措,所以我希望有人能给我一个新的、可靠的答案。
最佳答案
如果在终端中以您的用户帐户执行时 fork 和构建脚本工作正常,则很可能是环境变量和文件权限存在问题。
1 可能是 GRADLE_USER_HOME 中定义的路径对 www-data 用户不可写。要更改主目录,您可以在运行构建脚本之前执行 gradle -g/path/writable/by-www-user 或在 PHP putenv() 中使用来修改 'GRADLE_USER_HOME '.
如果您更改 GRADLE_USER_HOME,那么还要移动 gradle.properties 等文件,这对您的构建可能很重要。
2 查看gradle命令是否可以通过www-data执行
sudo -u www-data `gradle --version`
如何检查 www-user 和您的用户的环境变量:
您可以在终端中使用 printenv 来打印环境变量。例如,对于 www-data 用户,这将是 sudo -u www-data printenv 而对于您的用户,则只是 printenv
您可以将它们保存到文件中并进行比较
sudo -u www-data printenv > wwwdata-env
printenv > my-env
diff --side-by-side --suppress-common-lines wwwdata-env my-env
然后使用 PHP 方法 putenv() - 设置任何与 Gradle 和您构建的项目相关的缺失变量。
关于php - 无法为 Linux amd64 加载 native 库 'libnative-platform.so',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38519643/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我想为Heroku构建一个Rails3应用程序。他们使用Postgres作为他们的数据库,所以我通过MacPorts安装了postgres9.0。现在我需要一个postgresgem并且共识是出于性能原因你想要pggem。但是我对我得到的错误感到非常困惑当我尝试在rvm下通过geminstall安装pg时。我已经非常明确地指定了所有postgres目录的位置可以找到但仍然无法完成安装:$envARCHFLAGS='-archx86_64'geminstallpg--\--with-pg-config=/opt/local/var/db/postgresql90/defaultdb/po
我正在使用的第三方API的文档状态:"[O]urAPIonlyacceptspaddedBase64encodedstrings."什么是“填充的Base64编码字符串”以及如何在Ruby中生成它们。下面的代码是我第一次尝试创建转换为Base64的JSON格式数据。xa=Base64.encode64(a.to_json) 最佳答案 他们说的padding其实就是Base64本身的一部分。它是末尾的“=”和“==”。Base64将3个字节的数据包编码为4个编码字符。所以如果你的输入数据有长度n和n%3=1=>"=="末尾用于填充n%
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',
我已经从我的命令行中获得了一切,所以我可以运行rubymyfile并且它可以正常工作。但是当我尝试从sublime中运行它时,我得到了undefinedmethod`require_relative'formain:Object有人知道我的sublime设置中缺少什么吗?我正在使用OSX并安装了rvm。 最佳答案 或者,您可以只使用“require”,它应该可以正常工作。我认为“require_relative”仅适用于ruby1.9+ 关于ruby-主要:Objectwhenrun
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我已经像这样安装了一个新的Rails项目:$railsnewsite它执行并到达:bundleinstall但是当它似乎尝试安装依赖项时我得到了这个错误Gem::Ext::BuildError:ERROR:Failedtobuildgemnativeextension./System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/rubyextconf.rbcheckingforlibkern/OSAtomic.h...yescreatingMakefilemake"DESTDIR="cleanmake"DESTDIR="
关闭。这个问题需要detailsorclarity.它目前不接受答案。想改进这个问题吗?通过editingthispost添加细节并澄清问题.关闭8年前。Improvethisquestion在首页我有:汽车:VolvoSaabMercedesAudistatic_pages_spec.rb中的测试代码:it"shouldhavetherightselect"dovisithome_pathit{shouldhave_select('cars',:options=>['volvo','saab','mercedes','audi'])}end响应是rspec./spec/request