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

panics on termux #53

Closed
phanirithvij opened this issue Nov 5, 2022 · 6 comments · Fixed by #54
Closed

panics on termux #53

phanirithvij opened this issue Nov 5, 2022 · 6 comments · Fixed by #54
Assignees

Comments

@phanirithvij
Copy link

When I try to run a very simple minimal reproducible example

use webbrowser;

fn main() {
    if webbrowser::open("http://github.com").is_ok() {
        println!("hello, github.com");
    }
}

With webbrowser = "0.8.1" as the only dependency

# can be run on termux (rust required, `pkg install rust`)
# cargo install sample_webbrowser --git https://github.com/phanirithvij/sample_webbrowser && RUST_BACKTRACE=full sample_webbrowser

The output is

thread 'main' panicked at 'android context was not initialized', /data/data/com.termux/files/home/.cargo/registry/src/github.com-1ecc6299db9ec823/ndk-context-0.1.1/src/lib.rs:72:30
@phanirithvij phanirithvij changed the title fails on termux panics on termux Nov 5, 2022
@amodm
Copy link
Owner

amodm commented Nov 6, 2022

Based on this stackoverflow answer, it seems that Android APIs are not available to programs running inside Termux.

In this scenario, it'd be best to detect the Termux environment and solve for it separately, as against treating it as regular Android env. I'll search online to see what mechanisms others have used to detect Termux env, but if you have any ideas, I'd appreciate the help greatly.

@amodm
Copy link
Owner

amodm commented Nov 6, 2022

As of now, TERMUX_VERSION env var seems more appropriate, so I'll be proceeding with that as a way to detect the termux env in Android, unless you have better ideas.

@amodm amodm self-assigned this Nov 6, 2022
@amodm
Copy link
Owner

amodm commented Nov 6, 2022

@phanirithvij, please give the android-termux branch a shot. My local testing seems to show that this works, but I'll await your confirmation for a while before merging this.

@amodm
Copy link
Owner

amodm commented Nov 7, 2022

@phanirithvij in the absence of any confirmation from you, I'll be merging #54 on the basis of my local testing alone, by tomorrow. So if possible, please do give it a test run.

@amodm amodm closed this as completed in #54 Nov 8, 2022
@amodm
Copy link
Owner

amodm commented Nov 8, 2022

This is now released as v0.8.2

@phanirithvij
Copy link
Author

phanirithvij commented Nov 10, 2022

Works! Thanks for the quick fix and new release. Sorry for the late response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants