Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong host architectures for Java bindings (darwin-x64 -> darwin-x86-64) and others as well #491

Closed
1 task done
purejava opened this issue Jan 10, 2024 · 5 comments · Fixed by #498
Closed
1 task done
Labels
bug Something isn't working

Comments

@purejava
Copy link

purejava commented Jan 10, 2024

Steps To Reproduce

Use Java bindings for a real world project and deploy it to different host architectures

Expected Result

Java bindings allow to use the Bitwarden Secrets Manager SDK on all host architectures the bitwarden_c library was compiled for

Actual Result

Native library (darwin-x86-64/libbitwarden_c.dylib) not found in resource path for Apple Intel (darwin-x86-64)

Screenshots or Videos

No response

Additional Context

Thanks for providing the Bitwarden Secrets Manager SDK and including Java bindings a short while ago.

I used these to build a Java application, that is a plug-in for Cryptomator, to store vault passwords in Bitwarden Secrets Manager.

Cryptomator is available for Windows, Linux and Mac, both Apple Intel and Apple Silicon. So the plug-in, using the SDK, should work on these host architectures too.

It does on Apple Silicon, but fails to load on Apple Intel, see purejava/cryptomator-bitwarden#4.

The reason for that is, that libbitwarden_c.dylib cannot be found in the resource jar file, although it is contained.
Renaming the folder the libraries are stored in within the jar file from darwin-x64 to darwin-x86-64 solves the issue.

A note on Linux: this is probably a problem on other architectures too, as the libraries for Linux are stored in ubuntu-x64 instead of linux-x64, see here.

Your Node-API bindings for the different architectures.

Operating System

macOS

Operating System Version

Sonoma 14.2.1

Build Version

0.4.0-SNAPSHOT

Issue Tracking Info

  • I understand that work is tracked outside of Github. A PR will be linked to this issue should one be opened to address it, but Bitwarden doesn't use fields like "assigned", "milestone", or "project" to track progress.
@purejava purejava added the bug Something isn't working label Jan 10, 2024
@purejava
Copy link
Author

A note on Linux: this is probably a problem on other architectures too, as the libraries for Linux are stored in ubuntu-x64 instead of linux-x64, see here.

Some additional info: the same issue occurs on Windows 11 and Linuxes. Here is the relevant part of the stack-trace on Windows:

Native library (win32-x86-64/bitwarden_c.dll) not found in resource path ([file:/C:/Users/ralph/AppData/Roaming/Cryptomator/Plugins/cryptomator-bitwarden-0.4.0-SNAPSHOT.jar])

These paths are configured by the SDK versus used by JNA to load the bitwarden_c library:

Host SDK path JNA path
Apple Intel darwin-x64 darwin-x86-64
Arch Linux x86_64 / KUbuntu 23.10 x86_64 ubuntu-x64 linux-x86-64
Windows 11 x64 windows-x64 win32-x86-64

@purejava purejava changed the title Wrong host architectures for Java bindings (darwin-x64 -> darwin-x86-64) Wrong host architectures for Java bindings (darwin-x64 -> darwin-x86-64) and others as well Jan 11, 2024
@Hinton
Copy link
Member

Hinton commented Jan 11, 2024

Hi @purejava,

Thanks for reporting and investigating this. I took a look at the JNA source, and we should indeed be using x86-64.

I've let the team know about it and they are looking into it.

@Hinton
Copy link
Member

Hinton commented Jan 12, 2024

I've opened a fix. Unfortunately I don't currently have access to a x64 machine but I've asked internally if we have someone that can try it.

@purejava
Copy link
Author

Thanks for providing a new Maven package on GitHub. Unfortunately, it's not possible to use it as a dependency, as you used an invalid Maven version element <version>ps-fix-arch-SNAPSHOT</version>:

2024-01-18T05:07:23.7398538Z [INFO] Scanning for projects...
2024-01-18T05:07:23.8044952Z [INFO] 
2024-01-18T05:07:23.8049702Z [INFO] -----------------< org.***:cryptomator-bitwarden >-----------------
2024-01-18T05:07:23.8053903Z [INFO] Building cryptomator-bitwarden ps-fix-arch-SNAPSHOT
2024-01-18T05:07:23.8057367Z [INFO]   from pom.xml
2024-01-18T05:07:23.8060594Z [INFO] --------------------------------[ jar ]---------------------------------
2024-01-18T05:07:24.0925393Z [INFO] 
2024-01-18T05:07:24.0930060Z [INFO] --- maven-resources-plugin:3.3.1:resources (default-resources) @ cryptomator-bitwarden ---
2024-01-18T05:07:24.2098274Z [INFO] Copying 1 resource from src/main/resources to target/classes
2024-01-18T05:07:24.2154035Z [INFO] 
2024-01-18T05:07:24.2157931Z [INFO] --- maven-compiler-plugin:3.12.1:compile (default-compile) @ cryptomator-bitwarden ---
2024-01-18T05:07:24.3808527Z [INFO] Recompiling the module because of changed source code.
2024-01-18T05:07:24.3872516Z [INFO] Compiling 2 source files with javac [debug target 20 module-path] to target/classes
2024-01-18T05:07:24.4501218Z [INFO] ------------------------------------------------------------------------
2024-01-18T05:07:24.4505367Z [INFO] BUILD FAILURE
2024-01-18T05:07:24.4508777Z [INFO] ------------------------------------------------------------------------
2024-01-18T05:07:24.4512763Z [INFO] Total time:  0.732 s
2024-01-18T05:07:24.4530106Z [INFO] Finished at: 2024-01-18T05:07:24Z
2024-01-18T05:07:24.4533540Z [INFO] ------------------------------------------------------------------------
2024-01-18T05:07:24.4540739Z [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.12.1:compile (default-compile) on project cryptomator-bitwarden: Fatal error compiling: error: bad value for --module-version option: 'ps-fix-arch-SNAPSHOT' -> [Help 1]
2024-01-18T05:07:24.4546415Z [ERROR] 
2024-01-18T05:07:24.4549412Z [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
2024-01-18T05:07:24.4553413Z [ERROR] Re-run Maven using the -X switch to enable full debug logging.
2024-01-18T05:07:24.4556692Z [ERROR] 
2024-01-18T05:07:24.4560124Z [ERROR] For more information about the errors and possible solutions, please read the following articles:
2024-01-18T05:07:24.4565102Z [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
2024-01-18T05:07:24.4775626Z ##[error]Process completed with exit code 1.

Maven is very strict here, see here and here.

Could you please provide something valid as a successor of <version>0.4.0-SNAPSHOT</version> ?

Hinton added a commit that referenced this issue Jan 18, 2024
- Rename `ubuntu-x64` to `linux-x64` to better match the usage.
- Resolve java using the wrong prefixes. It should be `x86_64` for
architecture, and windows should use `win32`.

Resolves #491
@Hinton
Copy link
Member

Hinton commented Jan 18, 2024

Hi @purejava,

This is now merged and should be published as a versioned snapshot momentarily.

Note: We've successfully used branch snapshots in other projects albeit using gradle. From the error you got in your build I suspect it might be related to setting your project version, purejava/cryptomator-bitwarden@4625758#diff-9c5fb3d1b7e3b0f54bc5c4182965c4fe1f9023d449017cece3005d3f90e8e4d8L9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants