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

Browser not opening on Linux #4

Closed
Seeker14491 opened this issue Oct 22, 2019 · 13 comments
Closed

Browser not opening on Linux #4

Seeker14491 opened this issue Oct 22, 2019 · 13 comments
Labels
bug Something isn't working

Comments

@Seeker14491
Copy link
Owner

Under certain conditions, nothing happens when trying to open a website using opener::open, while manually using xdg-open works fine. I suspect this is due to spawning the command with a null stdout. This is the current code where the command is configured:

let mut cmd = Command::new(cmd)
        .args(extra_args)
        .arg(path)
        .stdin(stdin_type)
        .stdout(Stdio::null())
        .stderr(Stdio::piped())
        .spawn()?;

The reason null stdout was used was to prevent polluting the user's terminal with output from xdg-open.

@Seeker14491 Seeker14491 added the bug Something isn't working label Oct 22, 2019
@Seeker14491 Seeker14491 self-assigned this Oct 22, 2019
@Seeker14491
Copy link
Owner Author

@japrogramer continuing our discussion from rust-lang/rustup#1125, if you don't mind, I'd like you to check if my updated branch works for you by running the following commands.

First, confirm the bug triggers on the master branch:

git clone https://github.com/Seeker14491/opener.git
cd opener/opener-bin/
echo 'Hello' > index.html
cargo run -- index.html

If you get the message Opened path successfully., but nothing happens, you've triggered the bug.

Then, check if the inherit-stdio branch works correctly and opens your browser:

git checkout -f inherit-stdio
echo 'Hello' > index.html
cargo run -- index.html

@japrogramer
Copy link

japrogramer commented Oct 22, 2019

The first set of commands work.

▶ cargo run -- index.html                                                                     69%
   Compiling unicode-width v0.1.6
   Compiling rustc-demangle v0.1.16
   Compiling ansi_term v0.11.0
   Compiling cfg-if v0.1.10
   Compiling strsim v0.8.0
   Compiling vec_map v0.8.1
   Compiling opener v0.4.1 (/home/archangel/Code/Rust/opener/opener)
   Compiling libc v0.2.65
   Compiling bitflags v1.2.1
   Compiling textwrap v0.11.0
   Compiling atty v0.2.13
   Compiling backtrace-sys v0.1.32
   Compiling backtrace v0.3.40
   Compiling clap v2.33.0
   Compiling failure v0.1.6
   Compiling structopt v0.3.3
   Compiling opener-bin v0.1.0 (/home/archangel/Code/Rust/opener/opener-bin)
    Finished dev [unoptimized + debuginfo] target(s) in 13.75s
     Running `/home/archangel/Code/Rust/opener/target/debug/opener-bin index.html`
Opened path successfully.

and the second in the other branch also works

▶ cargo run -- index.html                                                                   67%
   Compiling proc-macro2 v1.0.6
   Compiling unicode-xid v0.2.0
   Compiling syn v1.0.5
   Compiling libc v0.2.65
   Compiling cc v1.0.46
   Compiling bitflags v1.2.1
   Compiling unicode-width v0.1.6
   Compiling unicode-segmentation v1.3.0
   Compiling failure_derive v0.1.6
   Compiling vec_map v0.8.1
   Compiling strsim v0.8.0
   Compiling rustc-demangle v0.1.16
   Compiling ansi_term v0.11.0
   Compiling cfg-if v0.1.10
   Compiling opener v0.4.1 (/home/archangel/Code/Rust/opener/opener)
   Compiling textwrap v0.11.0
   Compiling heck v0.3.1
   Compiling backtrace-sys v0.1.32
   Compiling atty v0.2.13
   Compiling clap v2.33.0
   Compiling quote v1.0.2
   Compiling backtrace v0.3.40
   Compiling proc-macro-error v0.2.6
   Compiling synstructure v0.12.1
   Compiling structopt-derive v0.3.3
   Compiling failure v0.1.6
   Compiling structopt v0.3.3
   Compiling opener-bin v0.1.0 (/home/archangel/Code/Rust/opener/opener-bin)
    Finished dev [unoptimized + debuginfo] target(s) in 28.58s
     Running `/home/archangel/Code/Rust/opener/target/debug/opener-bin index.html`
Opened path successfully.

but still this doesnt

rustup doc --std 
▶ rustup component add rust-docs                                                          
info: component 'rust-docs' for target 'x86_64-unknown-linux-gnu' is up to date
▶ uname -r; pacman -Q linux                                                                
5.3.6-arch1-1-ARCH
linux 5.3.7.arch1-1
▶ rustup --version                                                                         
rustup 1.20.2 (13979c968 2019-10-16)

@Seeker14491
Copy link
Owner Author

@japrogramer to be clear, the first set of commands opens your browser? If so, can you check if this command opens the docs in your browser (make sure to run on the master branch):

cargo run -- $(rustup doc --std --path)

If all these commands work fine, then maybe the problem really is in rustup.

@japrogramer
Copy link

Yes they work, But the rustup doc command doesn't

Here the index page i created works and the one pointing to std doesnt

Rust/opener/opener-bin  master ✗                                                                18d ◒  ⍉
▶ cargo run -- index.html                                                                      ∞
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `/home/archangel/Code/Rust/opener/target/debug/opener-bin index.html`
Opened path successfully.

Rust/opener/opener-bin  master ✗                                                                 18d ◒
▶ cargo run -- $(rustup doc --std --path)                                                       ∞
    Finished dev [unoptimized + debuginfo] target(s) in 0.04s
     Running `/home/archangel/Code/Rust/opener/target/debug/opener-bin /home/archangel/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/std/index.html`
Opened path successfully.

Rust/opener/opener-bin  master ✗                                                                 18d ◒
▶ rustup doc --std --path                                                                       ∞
/home/archangel/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/share/doc/rust/html/std/index.html

both files have the same permissions, and the std/index.html does have content

@japrogramer
Copy link

japrogramer commented Oct 23, 2019

@julienp17
Copy link

Same issue here, the following works

firefox $(rustup doc --path)

but not

firefox $(rustup doc)

which opens KTorrent for me. I followed some instructions from rustup doc appears to do nothing #1125, by removing

[Default Applications]
text/html=ktorrent.desktop

from ~/.config/mimeapps.list and replacing it with text/html=firefox.desktop but it didn't fix the issue.

My config:
5.5.3-arch1-1
linux 5.5.3.arch1-1
rustup 1.21.1 (2020-01-25)
rust-docs up to date

@Seeker14491
Copy link
Owner Author

I was never able to reproduce this issue locally, unfortunately. Anyways, I released v0.5 of this crate about two weeks ago, and it changes the strategy on Linux such that the system xdg-open is tried first if available. I'd like to know if this is still a problem with the new version. Note that a version of Rustup with the updated opener version still hasn't shipped, so to test this, a procedure like I described in #4 (comment) can be used.

@gdnathan
Copy link

as asked in here, i'll respond to this.

I use WSL, and xdg-open-wsl (which i can call with xdg-open on my system

@Seeker14491
Copy link
Owner Author

@Erudyx Ah, WSL should work fine with the release of v0.5. Still, if you want to confirm it's fixed now you can run what I posted above:

git clone https://github.com/Seeker14491/opener.git
cd opener/opener-bin/
echo 'Hello' > index.html
cargo run -- index.html

@gdnathan
Copy link

Its working fine, but i dont i dont know why rustup doc --book does nothing... no error printed, return 0...

@Seeker14491
Copy link
Owner Author

That's because the currently released version of rustup is using v0.4.1 of this crate. There hasn't been a rustup release since I made the PR updating to v0.5.

@gdnathan
Copy link

ooooh i get it, so this gonna be fixed when the pr is accepted, thanks for your time!

@Seeker14491 Seeker14491 removed their assignment Sep 4, 2021
@Seeker14491
Copy link
Owner Author

I'm closing this issue. Feel free to make a new issue if this is still a problem with the current version of the library.

@Seeker14491 Seeker14491 closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2023
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

No branches or pull requests

4 participants