Beastwick18/nyaa

Add termux support / workaround

Closed this issue · 16 comments

P0bo commented

I'm attempting to install nyaa on Termux, but I encountered several errors during the compilation process related to the Clipboard functionality in the arboard dependency. The errors suggest that certain platform-specific functionalities such as Clipboard, Clear, Get, and Set are not found in platform. This is preventing me from successfully installing and running nyaa on Termux.

Error details:

error[E0433]: failed to resolve: could not find `Clipboard` in `platform`
  --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:76:38
   |
76 |         Ok(Clipboard { platform: platform::Clipboard::new()? })
   |                                            ^^^^^^^^^ could not find `Clipboard` in `platform`

error[E0433]: failed to resolve: could not find `Clear` in `platform`
   --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:156:31
    |
156 |         Clear { platform: platform::Clear::new(&mut self.platform) }
    |                                     ^^^^^ could not find `Clear` in `platform`

error[E0433]: failed to resolve: could not find `Get` in `platform`
   --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:161:29
    |
161 |         Get { platform: platform::Get::new(&mut self.platform) }
    |                                   ^^^ could not find `Get` in `platform`

error[E0433]: failed to resolve: could not find `Set` in `platform`
   --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:166:29
    |
166 |         Set { platform: platform::Set::new(&mut self.platform) }
    |                                   ^^^ could not find `Set` in `platform`

error[E0412]: cannot find type `Clipboard` in module `platform`
  --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:65:33
   |
65 |     pub(crate) platform: platform::Clipboard,
   |                                    ^^^^^^^^^ not found in `platform`

error[E0412]: cannot find type `Get` in module `platform`
   --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:173:33
    |
173 |     pub(crate) platform: platform::Get<'clipboard>,
    |                                    ^^^ not found in `platform`

error[E0412]: cannot find type `Set` in module `platform`
   --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:197:33
    |
197 |     pub(crate) platform: platform::Set<'clipboard>,
    |                                    ^^^ not found in `platform`

error[E0412]: cannot find type `Clear` in module `platform`
   --> /storage/emulated/0/Termux/.cargo/registry/src/index.crates.io-6f17d22bba15001f/arboard-3.4.0/src/lib.rs:238:33
    |
238 |     pub(crate) platform: platform::Clear<'clipboard>,
    |                                    ^^^^^ not found in `platform`

Steps to Reproduce:

  1. Install Termux on an Android device.
  2. Attempt to install nyaa using Cargo in Termux.

Expected behavior:
The installation should complete successfully.

Actual behavior:
The installation fails with errors related to unresolved platform-specific functionalities.

Environment:

  • Termux
  • Rust version: 1.80.0
  • Cargo version: 1.8.0

Additional context:
It seems like the current implementation of nyaa does not support the Termux environment, likely due to missing platform-specific clipboard functionalities. Adding Termux support or providing a workaround for these functionalities would be greatly appreciated.

P0bo commented
Screenshot_2024-08-14-06-39-52-73_84d3000e3f4017145260f7618db1d683

When building form source we get this error

error: failed to run custom build command for `proc-macro2 v1.0.86`

Caused by:
  could not execute process `/storage/emulated/0/Termux/nyaa/target/release/build/proc-macro2-e03be08e04e6f282/build-script-build` (never executed)

Caused by:
  Permission denied (os error 13)
warning: build failed, waiting for other jobs to finish...
error: failed to compile `nyaa v0.9.1 (/storage/emulated/0/Termux/nyaa)`, intermediate artifacts can be found at `/storage/emulated/0/Termux/nyaa/target`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Latest commit seems to compile, but I'm having trouble getting it to run. Seems to be some issue with the backend ratatui uses (Crossterm) not being able to enter raw mode (required for keyboard input to work). Switching to Termion backend didn't seem to fix it either. I'll see if I can find a workaround.

P0bo commented

Thank you for your response and for looking into this issue!

Please continue to explore potential workarounds or alternative solutions to make nyaa compatible with Termux. Having support for Termux would be incredibly useful, and I'm sure many users would benefit from it.

Commit ab45266 should fix termux. Thanks for bringing this up, and let me know if it now works for you :)

Hello i was just looking into this , i did

git clone https://github.com/Beastwick18/nyaa
cd nyaa
cargo install --path .

but i ran into this

warning: be sure to add `/data/data/com.termux/files/home/.cargo/bin` to your PATH to be able to run the installed binaries
~/nyaa $ nyaa
No command nyaa found, did you mean:
 Command nona in package hugin from the x11-repo repository
 Command na6 in package ipv6toolkit
 Command nala in package nala
 Command nmap in package nmap
 Command ncat in package nmap-ncat
 Command yara in package yara
~/nyaa $
P0bo commented
  1. Open your .bashrc file
  nano ~/.bashrc
  1. Add the following line to the end of the file to include the Cargo binaries directory in your PATH:

    export PATH="$HOME/.cargo/bin:$PATH"
  2. Save and exit the text editor by pressing CTRL + X, then Y, and then Enter.

  3. Reload your shell configuration to apply the changes:

    source ~/.bashrc
  4. Now, try running the nyaa command again:

    nyaa
P0bo commented

@Beastwick18 i am able to run nyaa but i have ran into clipboard problems

Screenshot_2024-08-14-12-12-50-68_84d3000e3f4017145260f7618db1d683

Im not sure if termux supports osc52 clipboard functions. Maybe that's what causing this .

Termux should support it. The documentation indicates osc52 should be enabled by default, but for some reason that changed. Enabling it manually should fix the clipboard:

# In ~/.config/nyaa/config.toml
[clipboard]
osc52 = true

I've changed it to be enabled by default to match documentation 5cb0fd8. I'll update the error message to indicate whats going on: "There is no native clipboard support for android"

P0bo commented

That fixed it , thank you very much .

Awesome, I'll go ahead and close this then :D

@P0bo thank you very much , that helped it . @Beastwick18 i am unable to download multiple torrents at once , is it possible to get urls file instead when selected multiple torrents since batch downloading is not possible with android.

@onnesoom Batch downloading is working for me. Are you getting a specific error message?

To start batch downloading, you have to press Space on the torrents you want to download, then press Tab to focus the batch download pane, then press Ctrl+A to download all torrents.

Also, you'll want to select a download client that is already set up. The "Download Torrent File" client should work with no configuration. To select it, press d then move down to it and press Enter. It should save all torrent files to ~/Downloads/

I mean those are for clients that are already setup right ? what im asking is different download client options for batch and single download . since im on android only and i dont use terminal torrent clients , i download torrents with default client , which is aria2android or flud mostly . All android clients support single file download but they dont support rpc so i am not able bind them with differnt programs . so what i wanted is to have a differnt download clint options when downloding batch file , if i can get the urls file of all the selected torrents i can simply import that file to my torrent clients an they will add all the torrents to download .

https://nyaa.si/download/1228.torrent
https://nyaa.si/download/1229.torrent
https://nyaa.si/download/1230.torrent
https://nyaa.si/download/1231.torrent
https://nyaa.si/download/1246.torrent
https://nyaa.si/download/1278.torrent
https://nyaa.si/download/1220.torrent
https://nyaa.si/download/1291.torrent
https://nyaa.si/download/1294.torrent

And when i download single torrents i wont need urls file , i can just open the selected entry with default client , and termux will simply open that in my preferred client i set system wide.

So you want to have all the URLs written into a single file? Something like this should do that:

# In ~/.config/nyaa/config.toml
[client.command]
cmd = 'echo "{torrent}" >> ~/batchurls.txt'
shell_cmd = "sh -c"

You can switch over to the "Run Command" client to use it. This won't open the file in the default application, though.

it does work but i have to switch in between default and run command for Enter and Ctrl+A every time i need to download batch or single , is it possible that Ctrl+A runs command but Enter runs default app