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

Config: the default configuration file is ignored, and so is --conf #1065

Open
ildella opened this issue Jul 29, 2024 · 11 comments
Open

Config: the default configuration file is ignored, and so is --conf #1065

ildella opened this issue Jul 29, 2024 · 11 comments
Labels
bug Something isn't working

Comments

@ildella
Copy link

ildella commented Jul 29, 2024

Have you read the documentation?
Yes.

How did you configure electrs?

Is running on a raspberrypi with latest Raspian OS. I built it from scratch.

$ cat ~/.electrs/config.toml
[server]
electrum_rpc_addr = "127.0.0.1:50001"

[bitcoin]
network = "bitcoin"
daemon_dir = "/home/pi/zio/bitcoin"
cookie_file = "/home/pi/zio/bitcoin/.cookie"
db_dir = "/home/pi/zio/electrs/db"
log_filters = "TRACE"

Environment variables: none set
Arguments: none set

Debug output of configuration

$ ./target/release/electrs
Starting electrs 0.10.5 on aarch64 linux with Config { network: Bitcoin, db_path: "./db/bitcoin", db_log_dir: None, daemon_dir: "/home/pi/.bitcoin", daemon_auth: CookieFile("/home/pi/.bitcoin/.cookie"), daemon_rpc_addr: 127.0.0.1:8332, daemon_p2p_addr: 127.0.0.1:8333, electrum_rpc_addr: 127.0.0.1:50001, monitoring_addr: 127.0.0.1:4224, wait_duration: 10s, jsonrpc_timeout: 15s, index_batch_size: 10, index_lookup_limit: None, reindex_last_blocks: 0, auto_reindex: true, ignore_mempool: false, sync_once: false, skip_block_download_wait: false, disable_electrum_rpc: false, server_banner: "Welcome to electrs 0.10.5 (Electrum Rust Server)!", signet_magic: f9beb4d9, args: [] }
Error: electrs failed

Caused by:
    0: failed to open bitcoind cookie file: /home/pi/.bitcoin/.cookie
    1: No such file or directory (os error 2)

Expected behavior
I would expect the configuration to be loaded, as expected from the docs: https://github.com/romanz/electrs/blob/master/doc/config.md#configuration-files-and-priorities

Actual behavior
It is clear that electrs is starting using default configuration, looking for files in /home/pi/.bitcoin/ while my config states otherwise.

@ildella ildella added the bug Something isn't working label Jul 29, 2024
@Kixunil
Copy link
Contributor

Kixunil commented Jul 29, 2024

Firstly, are you sure you're using a recent version from this repository? Not forks made by other people as those tend to introduce incompatible changes. Also are you sure you're using a recent version? Are you sure you're launching it with correct HOME environment variable? Are you sure you're not using some kind of isolation like a container or funny systemd options?

Sorry if these seem like stupid questions but the code definitely worked last time I tested and also there weren't any changes. And the code looks correct to me so OS issues are more likely.

@ildella
Copy link
Author

ildella commented Jul 29, 2024

I am more than positive that something is wrong with what I do and not with the code. Still I did follow instructions to the letter.

  1. yes, git repo is this one.
  2. I did clone and build few days ago. A git pull just got me a few updates, I'll try again but it's very unlikely that is the problem.
  3. what is the correct HOME env var and why there is a correct one? As you see I run electrs without any additional params.
  4. I am not using any isolation container or other systemd option. I am starting it from the terminal with the command I pasted up there.

@ildella
Copy link
Author

ildella commented Jul 29, 2024

And to be clear, if I put the config in the command line like

/home/pi/apps/electrs/target/release/electrs --log-filters INFO --db-dir /home/pi/zio/electrs/db --electrum-rpc-addr="127.0.0.1:50001" --daemon-dir=/home/pi/zio/bitcoin

They are used and it starts. Is just that it does not load from the toml config.

@Kixunil
Copy link
Contributor

Kixunil commented Jul 29, 2024

3. what is the correct HOME env var and why there is a correct one? As you see I run electrs without any additional params.

It's normally set by the OS (see echo $HOME) but it gets messed up occasionally. It looks like it should be /home/pi in your case.

@Maj3re
Copy link

Maj3re commented Aug 7, 2024

I had a similar issue on a laptop, this solved it

#199 (comment)

@thnkman
Copy link

thnkman commented Sep 1, 2024

I had a similar issue. Seems the binary can't start if you call --conf from a none "standard" (hard coded) directory. In my init script, i had to cd into the path of the config file, or else it would refuse to read the file.

@Kixunil
Copy link
Contributor

Kixunil commented Sep 1, 2024

@thnkman what was the error message? Relative paths should work normally as any other.

@thnkman
Copy link

thnkman commented Sep 1, 2024

@thnkman what was the error message? Relative paths should work normally as any other.

IIRC It was along the lines of "No such file or directory"

@Kixunil
Copy link
Contributor

Kixunil commented Sep 2, 2024

Then you must've supplied a wrong path. --conf never failed me and never required me to cd or do whatever else.

@thnkman
Copy link

thnkman commented Sep 3, 2024

Then you must've supplied a wrong path. --conf never failed me and never required me to cd or do whatever else.

I spent some time trying to troubleshoot this. Here are my findings:

In my initscript, i have the following;
runuser -u "$USER" -- sh -c "$PRGNAM --conf $CONFDIR/config.toml >$LOGDIR/$PRGNAM.log 2>&1 & echo \$! >$PIDFILE"

When this line is executed, electrs will spit out a error:
Error: Failed to read configuration file electrs.toml: Permission denied (os error 13)

If i rename config.toml to electrs.toml:
Error: Failed to read configuration file /etc/electrs/electrs.toml: No such file or directory (os error 2)

Then, if i add --skip-default-conf-files to the runuser line in my initscript, every thing is fine.

This might be expected behavior, but it's a little counter intuitive, at least to me.

@Kixunil
Copy link
Contributor

Kixunil commented Sep 3, 2024

It's expected but I think we could improve the error message somehow. Electrs tries to read configuration from default locations first and merge it together with other things. --skip-default-conf-files is the correct way to handle your use case.

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