我该如何用蚂蚁作为普通用户(不需要sudo)cooja构建

发布于 2025-01-23 06:37:39 字数 4754 浏览 5 评论 0原文


Recently I started working on a project in IoT, using contiki-ng.
The problem I faced is when I tried to run cooja with:
$ ant run

〜/contiki-ng/tools/cooja下。 我尝试使用$ sudo ant run的构建失败

$ ant run
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Buildfile: /home/user/contiki-ng/tools/cooja/build.xml

init:

compile:

copy configs:

jar_cooja:
     [jar] Building jar: /home/user/contiki-ng/tools/cooja/dist/cooja.jar

jar:

init:

compile:

jar:

init:

mspsim:

init:

compile:

jar:

coffee:

init:

compile:
   [javac] Compiling 8 source files to /home/user/contiki-ng/tools/cooja/tools/coffee-manager/build
   [javac] Note: /home/user/contiki-ng/tools/cooja/tools/coffee-manager/org/contikios/coffee/CoffeeConfiguration.java uses or overrides a deprecated API.
   [javac] Note: Recompile with -Xlint:deprecation for details.

configs:

jar:
     [jar] Building jar: /home/user/contiki-ng/tools/cooja/tools/coffee-manager/coffee.jar
    [copy] Copying 1 file to /home/user/contiki-ng/tools/cooja/apps/mspsim/lib

compile:

copy:

jar:

init:

compile:

jar:

init:

clean:
  [delete] Deleting directory /home/user/contiki-ng/tools/cooja/apps/serial_socket/build

BUILD FAILED
/home/user/contiki-ng/tools/cooja/build.xml:200: The following error occurred while executing this line:
/home/user/contiki-ng/tools/cooja/apps/serial_socket/build.xml:23: Unable to delete file /home/user/contiki-ng/tools/cooja/apps/serial_socket/build/org/contikios/cooja/serialsocket/SerialSocketClient$5.class

Total time: 2 seconds

,并且它开始按应有的工作,没有问题



$ ant run -verbose 2>> log; cat log给出:

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true

BUILD FAILED
/home/user/contiki-ng/tools/cooja/build.xml:200: The following error occurred while executing this line:
/home/user/contiki-ng/tools/cooja/apps/serial_socket/build.xml:23: Unable to delete file /home/user/contiki-ng/tools/cooja/apps/serial_socket/build/org/contikios/cooja/serialsocket/SerialSocketClient$5.class
    at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:775)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:822)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:641)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
    at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at org.apache.tools.ant.Target.execute(Target.java:449)
    at org.apache.tools.ant.Target.performTasks(Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
    at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at org.apache.tools.ant.Target.execute(Target.java:449)
    at org.apache.tools.ant.Target.performTasks(Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
    at org.apache.tools.ant.Main.runBuild(Main.java:818)
    at org.apache.tools.ant.Main.startAnt(Main.java:223)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

Total time: 2 seconds

Recently I started working on a project in IoT, using contiki-ng.
The problem I faced is when I tried to run cooja with:

$ ant run

under ~/contiki-ng/tools/cooja.
the build failed

$ ant run
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
Buildfile: /home/user/contiki-ng/tools/cooja/build.xml

init:

compile:

copy configs:

jar_cooja:
     [jar] Building jar: /home/user/contiki-ng/tools/cooja/dist/cooja.jar

jar:

init:

compile:

jar:

init:

mspsim:

init:

compile:

jar:

coffee:

init:

compile:
   [javac] Compiling 8 source files to /home/user/contiki-ng/tools/cooja/tools/coffee-manager/build
   [javac] Note: /home/user/contiki-ng/tools/cooja/tools/coffee-manager/org/contikios/coffee/CoffeeConfiguration.java uses or overrides a deprecated API.
   [javac] Note: Recompile with -Xlint:deprecation for details.

configs:

jar:
     [jar] Building jar: /home/user/contiki-ng/tools/cooja/tools/coffee-manager/coffee.jar
    [copy] Copying 1 file to /home/user/contiki-ng/tools/cooja/apps/mspsim/lib

compile:

copy:

jar:

init:

compile:

jar:

init:

clean:
  [delete] Deleting directory /home/user/contiki-ng/tools/cooja/apps/serial_socket/build

BUILD FAILED
/home/user/contiki-ng/tools/cooja/build.xml:200: The following error occurred while executing this line:
/home/user/contiki-ng/tools/cooja/apps/serial_socket/build.xml:23: Unable to delete file /home/user/contiki-ng/tools/cooja/apps/serial_socket/build/org/contikios/cooja/serialsocket/SerialSocketClient$5.class

Total time: 2 seconds

I tried using $ sudo ant run , and it started working as it should, without a problem.
.
.
$ ant run -verbose 2>> log;cat log gives:

Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true

BUILD FAILED
/home/user/contiki-ng/tools/cooja/build.xml:200: The following error occurred while executing this line:
/home/user/contiki-ng/tools/cooja/apps/serial_socket/build.xml:23: Unable to delete file /home/user/contiki-ng/tools/cooja/apps/serial_socket/build/org/contikios/cooja/serialsocket/SerialSocketClient$5.class
    at org.apache.tools.ant.taskdefs.Delete.handle(Delete.java:775)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:822)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.removeDir(Delete.java:818)
    at org.apache.tools.ant.taskdefs.Delete.execute(Delete.java:641)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
    at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at org.apache.tools.ant.Target.execute(Target.java:449)
    at org.apache.tools.ant.Target.performTasks(Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
    at org.apache.tools.ant.helper.SingleCheckExecutor.executeTargets(SingleCheckExecutor.java:36)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
    at org.apache.tools.ant.taskdefs.Ant.execute(Ant.java:437)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:299)
    at jdk.internal.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:99)
    at org.apache.tools.ant.Task.perform(Task.java:350)
    at org.apache.tools.ant.Target.execute(Target.java:449)
    at org.apache.tools.ant.Target.performTasks(Target.java:470)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1401)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1374)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1264)
    at org.apache.tools.ant.Main.runBuild(Main.java:818)
    at org.apache.tools.ant.Main.startAnt(Main.java:223)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:284)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:101)

Total time: 2 seconds

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

染柒℉ 2025-01-30 06:37:40

我解决了问题,首先通过检查build.xml,定义运行的部分:

105.  <target name="run" depends="init, compile, jar, copy configs">
106.    <java fork="yes" dir="${build}" classname="org.contikios.cooja.Cooja" maxmemory="512m">
107.      <sysproperty key="user.language" value="en"/>
108.      <arg line="${args}"/>
109.      <env key="LD_LIBRARY_PATH" value="."/>
110.      <classpath>
111.        <pathelement path="${build}"/>
112.        <pathelement location="lib/jdom.jar"/>
113.        <pathelement location="lib/log4j.jar"/>
114.        <pathelement location="lib/syntaxpane-1.2.0.jar"/>
115.        <pathelement location="lib/swingx-all-1.6.4.jar"/>
116.      </classpath>
117.    </java>
118.  </target>

您可以看到它取决于jar

 18.   Build COOJA (dist/cooja.jar) and all default projects (MSPSim et al)
 19.   > ant jar

因此,检查jar部分:

196.  <target name="jar" depends="jar_cooja">
197.    <ant antfile="build.xml" dir="apps/mrm" target="jar" inheritAll="false"/>
198.    <ant antfile="build.xml" dir="apps/mspsim" target="jar" inheritAll="false"/>
199.    <ant antfile="build.xml" dir="apps/avrora" target="jar" inheritAll="false"/>
200.    <ant antfile="build.xml" dir="apps/serial_socket" target="jar" inheritAll="false"/>
201.    <ant antfile="build.xml" dir="apps/powertracker" target="jar" inheritAll="false"/>
202.  </target>

我可以看到它尝试操纵./ apps/serail_socket,但失败了。
因此,我检查了所有者和这些目录的正确许可:

$ ls -li | awk '{print $1, $3, $4, $NF}'
total   
drwxr-xr-x root root build
-rw-r--r-- user user build.xml
-rw-r--r-- root root cooja.config
drwxr-xr-x root root java
drwxr-xr-x root root lib
-rw-r--r-- root root serial-socket.jar

所有者是root而不是普通用户。也许我跑了:
git subpodule Update -Init -init -recursive命令sudo或其他东西。
所以我更改了这些文件和目录的所有者:
sudo chown -h -r用户./apps/serail_socket ./apps/powertracker

然后它的正常工作。

I solved the problem, first by checking the build.xml, the section where run is defined :

105.  <target name="run" depends="init, compile, jar, copy configs">
106.    <java fork="yes" dir="${build}" classname="org.contikios.cooja.Cooja" maxmemory="512m">
107.      <sysproperty key="user.language" value="en"/>
108.      <arg line="${args}"/>
109.      <env key="LD_LIBRARY_PATH" value="."/>
110.      <classpath>
111.        <pathelement path="${build}"/>
112.        <pathelement location="lib/jdom.jar"/>
113.        <pathelement location="lib/log4j.jar"/>
114.        <pathelement location="lib/syntaxpane-1.2.0.jar"/>
115.        <pathelement location="lib/swingx-all-1.6.4.jar"/>
116.      </classpath>
117.    </java>
118.  </target>

and you can see that its depends on jar.

 18.   Build COOJA (dist/cooja.jar) and all default projects (MSPSim et al)
 19.   > ant jar

so checking the jar section :

196.  <target name="jar" depends="jar_cooja">
197.    <ant antfile="build.xml" dir="apps/mrm" target="jar" inheritAll="false"/>
198.    <ant antfile="build.xml" dir="apps/mspsim" target="jar" inheritAll="false"/>
199.    <ant antfile="build.xml" dir="apps/avrora" target="jar" inheritAll="false"/>
200.    <ant antfile="build.xml" dir="apps/serial_socket" target="jar" inheritAll="false"/>
201.    <ant antfile="build.xml" dir="apps/powertracker" target="jar" inheritAll="false"/>
202.  </target>

I can see that it try to manipulate the ./apps/serail_socket but it failed.
so I checked then the owner and the right permission of those directories:

$ ls -li | awk '{print $1, $3, $4, $NF}'
total   
drwxr-xr-x root root build
-rw-r--r-- user user build.xml
-rw-r--r-- root root cooja.config
drwxr-xr-x root root java
drwxr-xr-x root root lib
-rw-r--r-- root root serial-socket.jar

The owner was root and not the normal user. maybe I ran the :
git submodule update --init --recursive command by mistake with sudo or something.
so I changed the owner of those files and directories :
sudo chown -h -R user ./apps/serail_socket ./apps/powertracker

And then its worked as it should.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文