Indexing a java 17 project using sourcegraph's scip-java - java-17

I am following the method given at:
https://sourcegraph.github.io/scip-java/docs/getting-started.html
From the root directory of a project I am running :
docker run -v $(pwd):/home/gradle sourcegraph/scip-java:latest scip-java index --build-tool=gradle
But on running this command I am getting the following errors:
Exception in thread "main" java.lang.IllegalAccessError: class com.sourcegraph.semanticdb_javac.SemanticdbPlugin (in unnamed module #0x1794d431) cannot access class com.sun.tools.javac.api.BasicJavacTask (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.api to unnamed module #0x1794d431
In the getting started guide it says that Java 17 requires custom --add-exports (https://sourcegraph.github.io/scip-java/docs/getting-started.html#java)
For Java 17 and newer versions, the following JVM options are required:
--add-exports jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
--add-exports jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
I have tried various ways to add these options but have not been able to do it correctly
(Following are some things I tried and the corresponding error I got)
docker run -e JAVA_OPTS="--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" -v $(pwd):/home/gradle sourcegraph/scip-java:latest scip-java index --build-tool=gradle
Using JVM version 'temurin:17'
Unrecognized option: --add-exports
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: --add-exports
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
docker run -e JAVA_OPTS="jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" -v $(pwd):/home/gradle sourcegraph/scip-java:latest scip-java index --build-tool=gradle
Using JVM version 'temurin:17'
Error: Could not find or load main class jdk.compiler.com.sun.tools.javac.api=ALL-UNNAMED
Error: Could not find or load main class jdk.compiler.com.sun.tools.javac.api=ALL-UNNAMED
I don't have very basic experience with Java programming, and currently, my main objective is to index a repository and test the Sourcegraph precise code intelligence tool.
(I am trying to index: https://github.com/spring-projects/spring-framework)
How can I add these JVM options?
Edit:
I tried using Holdger's way(from the comments) but still getting the same errors.
docker run -e JDK_JAVA_OPTIONS="--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED" -v $(pwd):/home/gradle sourcegraph/scip-java:latest scip-java index --build-tool=gradle
The error message I got was(It is just the part where the task fails):
NOTE: Picked up JDK_JAVA_OPTIONS: --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
Exception in thread "main" java.lang.IllegalAccessError: class com.sourcegraph.semanticdb_javac.SemanticdbPlugin (in unnamed module #0x1794d431) cannot access class com.sun.tools.javac.api.BasicJavacTask (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.api to unnamed module #0x1794d431
at com.sourcegraph.semanticdb_javac.SemanticdbPlugin.init(SemanticdbPlugin.java:19)
at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugin(BasicJavacTask.java:255)
at jdk.compiler/com.sun.tools.javac.api.BasicJavacTask.initPlugins(BasicJavacTask.java:229)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:292)
at jdk.compiler/com.sun.tools.javac.main.Main.compile(Main.java:176)
at jdk.compiler/com.sun.tools.javac.Main.compile(Main.java:64)
at jdk.compiler/com.sun.tools.javac.Main.main(Main.java:50)

I left a comment but didn't get a response. Hopefully, this works.
This should be fixed with this PR: https://github.com/sourcegraph/scip-java/pull/464
Try re-running
$ docker run -v $(pwd):/home/gradle sourcegraph/scip-java:latest scip-java index --build-tool=gradle

Related

Swift build for linux/amd64 fails with strange error

I have a swift app with the following dependencies:
.package(url: "https://github.com/apple/swift-nio.git", .upToNextMajor(from: "2.41.1")),
.package(url: "https://github.com/apple/swift-crypto.git", .upToNextMajor(from: "2.1.0"))
Building it locally to run in a docker container works. This is the command I use for that:
docker build -t <image-name>:v1 .
Given I am building on an M1 macbook, deploying the above to azure does not work, since it is built for arm64 arch. However, when I attempt to build for linux/amd64, the code fails. This is the docker command I am using:
docker build --platform=linux/amd64 -t <image-name>:v1 .
I have tried with buildx, but the failure is similar:
docker buildx build --platform=linux/amd64 -t <image-name>:v1 .
The command I use to build the app for production is this:
RUN swift build -c release --static-swift-stdlib
Here is a snippet of the error message I am getting:
#0 35.45 warning: 'build': 'Build' was identified as an executable target given the presence of a 'main.swift' file. Starting with tools version 5.4.0 executable targets should be declared as 'executableTarget()'
#0 35.67 Building for production...
#0 36.08 [0/422] Compiling _AtomicsShims.c
#0 36.28 [1/422] Compiling CNIOWindows shim.c
#0 36.48 [2/422] Compiling CNIOWindows WSAStartup.c
#0 36.51 error: command Compiling CNIOLinux shim.c failed: failed to poll (Interrupted system call)
...
#0 44.33 remark: Incremental compilation has been disabled: it is not compatible with
whole module optimization
#0 44.34 error: command Compiling Swift Module 'NIOConcurrencyHelpers' (5 sources) failed: failed to poll (Interrupted system call)
#0 47.29 error: command Compiling CCryptoBoringSSL crypto/x509v3/v3_skey.c failed: failed to poll (Interrupted system call)
#0 47.64 error: command Compiling CCryptoBoringSSL crypto/x509v3/v3_purp.c failed: failed to poll (Interrupted system call)

VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory

I am trying to install kubeadm and for this i am trying to create vagrant environment i clone this link "https://github.com/kodekloudhub/certified-kubernetes-administrator-course" to my server and then run the command "vagrant up". I take this error.I am using Ubuntu 20.04.5 LTS
==> kubemaster: Clearing any previously set network interfaces...
There was an error while executing VBoxManage, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["hostonlyif", "create"]
Stderr: 0%...
Progress state: NS_ERROR_FAILURE
VBoxManage: error: Failed to create the host-only adapter
VBoxManage: error: VBoxNetAdpCtl: Error while adding new interface: failed to open /dev/vboxnetctl: No such file or directory
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component HostNetworkInterfaceWrap, interface IHostNetworkInterface
VBoxManage: error: Context: "RTEXITCODE handleCreate(HandlerArg*)" at line 95 of file VBoxManageHostonly.cpp
i want to create vagrant environment
This problem was solved by downgrading the "VirtualBox" version. Try to install version 6.38.

Execution Chef Cookbook using chef-solo

I am trying to execute chef solo on my windows vm locally using Powershell. (I am trying to execute cookbook during provisioning customise Windows VM on cloud)
All cookbook recipe dependencies are available within the cookbook.
Create solo.rb for recipe execution & web.json to run recipe.
"type": "powershell",
"inline": "chef-client --chef-license=accept -z -o cookbooks\\cookbook_workstation"
Error:
WARN: Failed to read the private key C:\chef\client.pem: #<Errno::ENOENT: No such file or directory # rb_sysopen - C:\chef\client.pem>
WARN: Error while reporting run start to Data Collector. URL: https://localhost:443/data-collector Exception: No HTTP Code -- I cannot read C:\chef\client.pem, which you told me to use to sign requests!
FATAL: NoMethodError: undefined method logger' for nil:NilClass <internal:warning>:43:in warn': warning: Chef::Compliance::Runner#logger at C:/opscode/chef/embedded/lib/ruby/2.7.0/forwardable.rb:154 forwarding to private method NilClass#logger (StructuredWarnings::BuiltInWarning)
Using chef-solo so I don't need chef server - how can I overcome client.pem WARN and logger issue. Pointers would be very helpful

Swift Perfect Docker Debugging the build process

I am woking on Swift Perfect server programming. My code is compiling on MacOS successfully and able to run on localhost. But, when I try with Linux build in Perfect Assistant, it is giving following error
unable to execute command: Killed
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
Failed: systemError(1, "sh: no job control in this shell\n<unknown>:0: error: build had 1 command failures\nswift-build: error: exit(1): /swift-3.0.2-RELEASE-ubuntu16.04/usr/bin/swift-build-tool -f /perfectbuild/.build_lin/release.yaml\n")
Tired of figuring out where the problem is and how to debug it. I'm new to docker as well. Please guide me regarding this.
When I try making linux executable I'm getting the following error
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \".build_lin/debug/S-server\": stat .build_lin/debug/S-server: no such file or directory".

i running a cookbook from github. it throws error: recipe not found but if i run other recipes from that cookbook its runs fine

i took a cookbook from github and am running chef-client. it gives me the error recipe not found but if i run other recipes from that cookbook its runs fine
root#vagrant-ubuntu-trusty-64:~# chef-client
Starting Chef Client, version 12.16.42
resolving cookbooks for run list: ["task_postgis::postgre_extension"]
Synchronizing Cookbooks:
- task_postgis (0.1.0)
- database (6.1.1)
- postgresql (5.1.0)
- apt (5.0.0)
- compat_resource (12.16.2)
- build-essential (7.0.2)
- seven_zip (2.0.2)
- windows (2.1.1)
- ohai (4.2.2)
- mingw (1.2.4)
- openssl (6.0.0)
Installing Cookbook Gems:
Compiling Cookbooks...
[2016-12-05T10:04:51+00:00] WARN: Chef::Provider::AptRepository already exists! Cannot create deprecation class for LWRP provider apt_repository from cookbook apt
[2016-12-05T10:04:52+00:00] WARN: AptRepository already exists! Deprecation class overwrites Custom resource apt_repository from cookbook apt
================================================================================
Recipe Compile Error
Chef::Exceptions::RecipeNotFound
could not find recipe setup_extensions for cookbook postgresql
Cookbook Trace:
/var/chef/cache/cookbooks/task_postgis/recipes/postgre_extension.rb:1:in `from_file'
Relevant File Content:
/var/chef/cache/cookbooks/task_postgis/recipes/postgre_extension.rb:
1>> include_recipe 'postgresql::setup_extensions'
2: # install extensions to database
3: postgresql_extension "postgis" do
4: database "mydb"
5: end
6:
7: #postgresql_language "plpgsql" do
8: # database "mydb"
9: #end
10:
Platform:
x86_64-linux
Running handlers:
[2016-12-05T10:04:52+00:00] ERROR: Running exception handlers
Running handlers complete
[2016-12-05T10:04:52+00:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 14 seconds
[2016-12-05T10:04:53+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-12-05T10:04:53+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-12-05T10:04:53+00:00] ERROR: could not find recipe setup_extensions for cookbook postgresql
[2016-12-05T10:04:53+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
There is no setup_extensions recipe in community postgresql cookbook. I'm not sure if there ever was such recipe. Where did you get this snippet?