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

Failed to read the configuration file. Try to run the application with admin permission #873

Open
sven-hergenhahn-dmtech opened this issue Dec 11, 2024 · 12 comments

Comments

@sven-hergenhahn-dmtech
Copy link

Describe the bug

A freshly installed crowdin (via brew as well as via crowdin-cli.zip and the install script) fails with

/opt/homebrew/opt/crowdin@4/bin/crowdin download sources
❌ Failed to read the configuration file. Try to run the application with admin permission
❌ class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')

I have absolutely no idea what the problem might be here.

The directory has drwxr-xr-x and the crowdin file -rw-r--r-- which should IHMO be fine.

I also tested with the example crowdin.yml file which I expectecd to complain about a wrong project ID or api_token, but the error remains the same.

To Reproduce
Steps to reproduce the behavior:

brew install crowdin@4
/opt/homebrew/opt/crowdin@4/bin/crowdin -V # shows 4.1.1

cd folder_with_example_crowdin_file
/opt/homebrew/opt/crowdin@4/bin/crowdin pull --debug

Error:
java.lang.RuntimeException: Failed to read the configuration file. Try to run the application with admin permission
at com.crowdin.cli.utils.file.FileUtils.readYamlFile(FileUtils.java:39)
at com.crowdin.cli.properties.PropertiesBuilders.buildPropertiesWithFiles(PropertiesBuilders.java:17)
at com.crowdin.cli.commands.picocli.ActCommandWithFiles.getProperties(ActCommandWithFiles.java:25)
at com.crowdin.cli.commands.picocli.ActCommandWithFiles.getProperties(ActCommandWithFiles.java:11)
at com.crowdin.cli.commands.picocli.GenericActCommand.run(GenericActCommand.java:27)
at picocli.CommandLine.executeUserObject(CommandLine.java:2030)
at picocli.CommandLine.access$1500(CommandLine.java:148)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
at picocli.CommandLine.execute(CommandLine.java:2174)
at com.crowdin.cli.commands.picocli.PicocliRunner.execute(PicocliRunner.java:38)
at com.crowdin.cli.Cli.main(Cli.java:16)
Caused by: java.lang.ClassCastException: class java.lang.String cannot be cast to class java.util.Map (java.lang.String and java.util.Map are in module java.base of loader 'bootstrap')
at com.crowdin.cli.utils.file.FileUtils.readYamlFile(FileUtils.java:35)
... 14 more

Expected behavior
Run crowdin as expected

Environment:

  • OS: MacOS
  • Version 14.7.1
  • java --version
    openjdk 23.0.1 2024-10-15
    OpenJDK Runtime Environment Homebrew (build 23.0.1)
    OpenJDK 64-Bit Server VM Homebrew (build 23.0.1, mixed mode, sharing)

Additional context
My config file works fine with the docker container:

docker run -ti --rm -v=$(pwd):/usr/crowdin-project crowdin/cli crowdin upload sources

@andrii-bodnar
Copy link
Member

Hi @sven-hergenhahn-dmtech, could you please share your crowdin.yml configuration file?

@sven-hergenhahn-dmtech
Copy link
Author

sven-hergenhahn-dmtech commented Dec 12, 2024

Hi, as said, I also used the one provided by the documentation, that would be

"project_id": "projectId"
"api_token": "personal-access-token"
"base_path": "."
"base_url": "https://api.crowdin.com"

"preserve_hierarchy": true

"files": [
  {
    "source": "/locale/en/folder1/[0-2].txt",
    "translation": "/locale/%two_letters_code%/folder1/%original_file_name%"
  },
]

and my own one - adjusted a little bit for privacy:

"project_id": "104"
"api_token": "some.very.long.token"
"base_path": "."
"base_url": "https://mycompany.api.crowdin.com"
# "preserve_hierarchy": true
"files": [
  {
    "source": "/source.json",
    "translation": "/translations/%locale_with_underscore%.json",
  }
]

@andrii-bodnar
Copy link
Member

andrii-bodnar commented Dec 12, 2024

@sven-hergenhahn-dmtech Thanks for the details! Looking at the error message, it seems like it's a YML reading error, but I just tried both of your configuration files and couldn't reproduce it.

Could you please try to recreate your config file and try the following syntax:

project_id: "projectId"
api_token: "personal-access-token"
base_path: "."
base_url: "https://api.crowdin.com"

preserve_hierarchy: true

files:
  - source: "/locale/en/folder1/[0-2].txt"
    translation: "/locale/%two_letters_code%/folder1/%original_file_name%"

@sven-hergenhahn-dmtech
Copy link
Author

did that, same result

@andrii-bodnar
Copy link
Member

Does this happen with all CLI commands?

@sven-hergenhahn-dmtech
Copy link
Author

well, I now tried

  • pull
  • upload
  • status
  • task list
  • config lint

want me to test more?

@sven-hergenhahn-dmtech
Copy link
Author

interestingly enough, when I delete/rename my crowdin.yml file, I get the same error. To me it seems like it does not detect the file at all...

@andrii-bodnar
Copy link
Member

I think it might be using a different configuration file. Please check for example $HOME/.crowdin.yml or try to find out where it gets the configuration from.

@sven-hergenhahn-dmtech
Copy link
Author

/opt/homebrew/Cellar/crowdin@4/4.4.1/bin/crowdin config lint --config ./crowdin.yml --debug

also fails with the same error though

@sven-hergenhahn-dmtech
Copy link
Author

all right, there was an old $HOME/.crowdin.yml that seems to have broken everything, even when explicitely specifying the local one. It only containes a line

api_token:sometoken

and some comments

It works now, but I'd still cosider this a bug - specifically when providing a local config file as --config param, I'd expect the one in $HOME to be ignored.

Thanks for your help anyway

@andrii-bodnar
Copy link
Member

Glad to hear this is resolved now!

The $HOME/.crowdin.yml configuration is loaded independently of the --config parameter, as it serves a different purpose - Split Project Configuration and API Credentials.

@sven-hergenhahn-dmtech
Copy link
Author

Looking at https://crowdin.github.io/crowdin-cli/configuration#split-project-configuration-and-api-credentials, the file is supposed to contain api_token lines - only mine was missing quotes for the value.

Maybe it would be helpful to provide a better error message that also mentions all config files that were used to gather configuration information

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

No branches or pull requests

2 participants