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

Kotlinc not found #233

Open
vchernyshov opened this issue Jul 25, 2022 · 15 comments
Open

Kotlinc not found #233

vchernyshov opened this issue Jul 25, 2022 · 15 comments

Comments

@vchernyshov
Copy link

vchernyshov commented Jul 25, 2022

Hi, getting the error when running Danger Kotlin on TeamCity CI:
sh: 1: kotlinc: not found
But kotlinc is installed at:
/usr/local/kotlinc/bin/kotlinc

Do you happen to know how to solve this?

@gianluz
Copy link
Member

gianluz commented Jul 25, 2022

Hi @vchernyshov thanks for this issue!
Unfortunately never had a chance to try danger kotlin on TeamCity CI, but from what you are describing seems like for some funny reasons kotlinc is not accessible from there.
Might help if you can share the script you are using for the danger step in your CI.
One thing you can do is add to your PATH variable /usr/local/kotlinc/bin.
to make sure kotlinc is visible and working you can try to add a command before thedanger-kotlin ci to check: kotlinc -version and check the CI log for errors.

@vchernyshov
Copy link
Author

@gianluz here my install script:

gem uninstall -aIx danger
sudo apt-get update
sudo apt-get install -y nodejs
sudo apt-get install -y npm
sudo apt-get install -y libncurses5
bash <(curl -s https://raw.githubusercontent.com/danger/kotlin/master/scripts/install.sh)
echo 'export KOTLIN_HOME=/usr/local/bin/kotlin' >> ~/.bash_profile
echo 'export PATH=$PATH:$KOTLIN_HOME/bin' >> ~/.bash_profile
source ~/.bash_profile
kotlin -version
which kotlinc

Next I'm installing the plugin:

INSTALL_PATH_PLUGIN=/usr/local/lib/danger/libs
PLUGIN_NAME=danger-shared.jar
mkdir -p $INSTALL_PATH_PLUGIN
cp -f $PLUGIN_NAME $INSTALL_PATH_PLUGIN/$PLUGIN_NAME

And running danger:

danger-kotlin pr PR_URL_HERE --verbose

And here the output:

[15:43:12] :	 [Step 5/38] mkdir -p /usr/local/bin
[15:43:12] :	 [Step 5/38] mkdir -p /usr/local/lib/danger
[15:43:12] :	 [Step 5/38] mkdir -p /usr/local/lib/danger/libs
[15:43:12] :	 [Step 5/38] cp -f danger-kotlin/build/bin/runner/releaseExecutable/danger-kotlin.kexe /usr/local/bin/danger-kotlin
[15:43:12] :	 [Step 5/38] cp -f danger-kotlin-library/build/libs/danger-kotlin.jar /usr/local/lib/danger/danger-kotlin.jar
[15:43:13] :	 [Step 5/38] Kotlin version 1.4.31-release-344 (JRE 11.0.14+9-Ubuntu-0ubuntu2.20.04)
[15:43:13] :	 [Step 5/38] /usr/local/kotlinc/bin/kotlinc
[15:43:13] :	 [Step 5/38]  [0;0mStarting Danger-Kotlin 1.1.0 with args 'pr, https://bitbucket.org/#######/#######-android/pull-requests/30715, --verbose' [0;0m
[15:43:13] :	 [Step 5/38]  [0;0mLaunching Danger-JS [0;0m
[15:43:13] :	 [Step 5/38]  [0;0mExecuting $(which danger) pr --process danger-kotlin --passURLForDSL https://bitbucket.org/#######/#######-android/pull-requests/30715 --verbose - pid 11932 [0;0m
[15:43:13] :	 [Step 5/38] Starting Danger PR on #######/#######-android#30715
[15:43:22] :	 [Step 5/38]  [0;0mStarting Danger-Kotlin 1.1.0 with args 'runner, /usr/local/lib/node_modules/danger/distribution/commands/danger-pr.js, --process, danger-kotlin, --passURLForDSL, https://bitbucket.org/#######/#######-android/pull-requests/30715, --verbose' [0;0m
[15:43:22] :	 [Step 5/38]  [0;0mGot Danger DSL path danger://dsl//opt/teamcity/temp/buildTmp/danger-dsl.json [0;0m
[15:43:22] :	 [Step 5/38]  [0;0mStripped DSL Path /opt/teamcity/temp/buildTmp/danger-dsl.json [0;0m
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38]  [0;0mCompiling Dangerfile Dangerfile.df.kts [0;0m
[15:43:22] :	 [Step 5/38]  [0;0mExecuting kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json - pid 11953 [0;0m
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] sh: 1: kotlinc: not found
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] Uncaught Kotlin exception: kotlin.Exception: Command kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json exited with code 32512
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.cmd.dangerfile.DangerFile#execute(kotlin.String;kotlin.String){} (0x41e271)
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.DangerKotlin#run(){} (0x41c68f)
[15:43:22] :	 [Step 5/38]     at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b6f7)
[15:43:22] :	 [Step 5/38]     at Init_and_run_start (0x44c656)
[15:43:22] :	 [Step 5/38]     at __libc_start_main (0x7f8fa5e480b3)
[15:43:22] :	 [Step 5/38]     at  (0x405031)
[15:43:22] :	 [Step 5/38]     at  ((nil))
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] Danger: ⅹ Failing the build, there is 1 fail.
[15:43:22] :	 [Step 5/38] ## Failures
[15:43:22] :	 [Step 5/38] `danger-kotlin` failed.
[15:43:22] :	 [Step 5/38] ## Markdowns
[15:43:22] :	 [Step 5/38] ### Log
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] ```sh
[15:43:22] :	 [Step 5/38]  [0;0mStarting Danger-Kotlin 1.1.0 with args 'runner, /usr/local/lib/node_modules/danger/distribution/commands/danger-pr.js, --process, danger-kotlin, --passURLForDSL, https://bitbucket.org/#######/#######-android/pull-requests/30715, --verbose' [0;0m
[15:43:22] :	 [Step 5/38]  [0;0mGot Danger DSL path danger://dsl//opt/teamcity/temp/buildTmp/danger-dsl.json [0;0m
[15:43:22] :	 [Step 5/38]  [0;0mStripped DSL Path /opt/teamcity/temp/buildTmp/danger-dsl.json [0;0m
[15:43:22] :	 [Step 5/38]  [0;0mCompiling Dangerfile Dangerfile.df.kts [0;0m
[15:43:22] :	 [Step 5/38]  [0;0mExecuting kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json - pid 11953 [0;0m
[15:43:22] :	 [Step 5/38] Uncaught Kotlin exception: kotlin.Exception: Command kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json exited with code 32512
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.cmd.dangerfile.DangerFile#execute(kotlin.String;kotlin.String){} (0x41e271)
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.DangerKotlin#run(){} (0x41c68f)
[15:43:22] :	 [Step 5/38]     at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b6f7)
[15:43:22] :	 [Step 5/38]     at Init_and_run_start (0x44c656)
[15:43:22] :	 [Step 5/38]     at __libc_start_main (0x7f8fa5e480b3)
[15:43:22] :	 [Step 5/38]     at  (0x405031)
[15:43:22] :	 [Step 5/38]     at  ((nil))
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] ```
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] 
[15:43:22] :	 [Step 5/38] Uncaught Kotlin exception: kotlin.Exception: Command $(which danger) pr --process danger-kotlin --passURLForDSL https://bitbucket.org/#######/#######-android/pull-requests/30715 --verbose exited with code 256
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)
[15:43:22] :	 [Step 5/38]     at kfun:systems.danger.cmd.dangerjs.DangerJS#process(systems.danger.cmd.Command;kotlin.String;kotlin.collections.List<kotlin.String>){} (0x41f2bb)
[15:43:22] :	 [Step 5/38]     at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b95b)
[15:43:22] :	 [Step 5/38]     at Init_and_run_start (0x44c656)
[15:43:22] :	 [Step 5/38]     at __libc_start_main (0x7fc5e1f850b3)
[15:43:22] :	 [Step 5/38]     at  (0x405031)
[15:43:22] :	 [Step 5/38]     at  ((nil))
[15:43:22]W:	 [Step 5/38] Process exited with code 1

@gianluz
Copy link
Member

gianluz commented Jul 26, 2022

The command danger-kotlin pr is reserved for running danger locally with a given PR url. Inside your CI danger kotlin step the correct command to use is danger-kotlin ci --dangerfile /path/to/Dangerfile.df.kts

Other thing you can do to see more logs that might help us to catch the problem is to add the debug flag like that:

DEBUG='*' danger-kotlin ci --dangerfile path/to/Dangerfile.df.kts

@vchernyshov
Copy link
Author

vchernyshov commented Jul 26, 2022

@gianluz I have tried danger-kotlin ci but got an error that this is not a PR

@gianluz
Copy link
Member

gianluz commented Jul 26, 2022

from your logs i can also see you are exporting the kotlin path but not kotlinc path

@vchernyshov
Copy link
Author

@gianluz I have changed the command and got this: Skipping Danger due to this run not executing on a PR.
How I can force to run danger?

@vchernyshov
Copy link
Author

@gianluz I have manage to force danger and got this results:

[12:18:55] :	 [Step 5/38] mkdir -p /usr/local/bin
[12:18:55] :	 [Step 5/38] mkdir -p /usr/local/lib/danger
[12:18:55] :	 [Step 5/38] mkdir -p /usr/local/lib/danger/libs
[12:18:55] :	 [Step 5/38] cp -f danger-kotlin/build/bin/runner/releaseExecutable/danger-kotlin.kexe /usr/local/bin/danger-kotlin
[12:18:55] :	 [Step 5/38] cp -f danger-kotlin-library/build/libs/danger-kotlin.jar /usr/local/lib/danger/danger-kotlin.jar
[12:18:55] :	 [Step 5/38] Kotlin version 1.4.31-release-344 (JRE 11.0.14+9-Ubuntu-0ubuntu2.20.04)
[12:18:56]W:	 [Step 5/38] info: kotlinc-jvm 1.4.31 (JRE 11.0.14+9-Ubuntu-0ubuntu2.20.04)
[12:18:57]W:	 [Step 5/38] WARNING: An illegal reflective access operation has occurred
[12:18:57]W:	 [Step 5/38] WARNING: Illegal reflective access by com.intellij.util.ReflectionUtil to method java.util.ResourceBundle.setParent(java.util.ResourceBundle)
[12:18:57]W:	 [Step 5/38] WARNING: Please consider reporting this to the maintainers of com.intellij.util.ReflectionUtil
[12:18:57]W:	 [Step 5/38] WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
[12:18:57]W:	 [Step 5/38] WARNING: All illegal access operations will be denied in a future release
[12:18:57] :	 [Step 5/38] /usr/local/kotlinc/bin/kotlinc
[12:18:57] :	 [Step 5/38]  [0;0mStarting Danger-Kotlin 1.1.0 with args 'ci' [0;0m
[12:18:57] :	 [Step 5/38]  [0;0mLaunching Danger-JS [0;0m
[12:18:57] :	 [Step 5/38]  [0;0mExecuting $(which danger) ci --process danger-kotlin --passURLForDSL  - pid 13115 [0;0m
[12:18:58]W:	 [Step 5/38] 2022-07-26T12:18:58.224Z danger:process_runner Debug mode on for Danger v11.1.1
[12:18:58]W:	 [Step 5/38] 2022-07-26T12:18:58.225Z danger:process_runner Starting sub-process run
[12:18:58]W:	 [Step 5/38] 2022-07-26T12:18:58.230Z danger:BitBucketCloudAPI GET https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715/diff
[12:19:04]W:	 [Step 5/38] 2022-07-26T12:19:04.572Z danger:BitBucketCloudAPI GET https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715/commits
[12:19:07]W:	 [Step 5/38] 2022-07-26T12:19:07.816Z danger:BitBucketCloudAPI GET https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715
[12:19:08]W:	 [Step 5/38] 2022-07-26T12:19:08.441Z danger:BitBucketCloudAPI GET https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715/comments?q=deleted=false
[12:19:08]W:	 [Step 5/38] 2022-07-26T12:19:08.928Z danger:BitBucketCloudAPI GET https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715/activity
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.562Z danger:process_runner { dangerJSONDSL:
[12:19:09]W:	 [Step 5/38]    { git:
[12:19:09]W:	 [Step 5/38]       { modified_files: [Array],
[12:19:09]W:	 [Step 5/38]         created_files: [],
[12:19:09]W:	 [Step 5/38]         deleted_files: [],
[12:19:09]W:	 [Step 5/38]         commits: [Array] },
[12:19:09]W:	 [Step 5/38]      bitbucket_cloud:
[12:19:09]W:	 [Step 5/38]       { metadata: [Object],
[12:19:09]W:	 [Step 5/38]         pr: [Object],
[12:19:09]W:	 [Step 5/38]         commits: [Array],
[12:19:09]W:	 [Step 5/38]         comments: [Array],
[12:19:09]W:	 [Step 5/38]         activities: [Array] },
[12:19:09]W:	 [Step 5/38]      settings: { github: [Object], cliArgs: [Object] } } }
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.562Z danger:process_runner Preparing to run: danger-kotlin,runner,/usr/local/lib/node_modules/danger/distribution/commands/danger-ci.js,--process,danger-kotlin,--passURLForDSL
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.563Z danger:runDangerSubprocess Running sub-process: danger-kotlin - runner,/usr/local/lib/node_modules/danger/distribution/commands/danger-ci.js,--process,danger-kotlin,--passURLForDSL
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.567Z danger:runDangerSubprocess Started passing in STDIN via the URL: danger://dsl//opt/teamcity/temp/buildTmp/danger-dsl.json
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.567Z danger:runDangerSubprocess Passed DSL in via STDIN
[12:19:09] :	 [Step 5/38]  [0;0mStarting Danger-Kotlin 1.1.0 with args 'runner, /usr/local/lib/node_modules/danger/distribution/commands/danger-ci.js, --process, danger-kotlin, --passURLForDSL' [0;0m
[12:19:09] :	 [Step 5/38]  [0;0mGot Danger DSL path danger://dsl//opt/teamcity/temp/buildTmp/danger-dsl.json [0;0m
[12:19:09] :	 [Step 5/38]  [0;0mStripped DSL Path /opt/teamcity/temp/buildTmp/danger-dsl.json [0;0m
[12:19:09] :	 [Step 5/38] 
[12:19:09] :	 [Step 5/38]  [0;0mCompiling Dangerfile Dangerfile.df.kts [0;0m
[12:19:09] :	 [Step 5/38]  [0;0mExecuting kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json - pid 13136 [0;0m
[12:19:09] :	 [Step 5/38] 
[12:19:09] :	 [Step 5/38] sh: 1: kotlinc: not found
[12:19:09] :	 [Step 5/38] 
[12:19:09] :	 [Step 5/38] Uncaught Kotlin exception: kotlin.Exception: Command kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json exited with code 32512
[12:19:09] :	 [Step 5/38] 
[12:19:09] :	 [Step 5/38]     at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)
[12:19:09] :	 [Step 5/38]     at kfun:systems.danger.cmd.dangerfile.DangerFile#execute(kotlin.String;kotlin.String){} (0x41e271)
[12:19:09] :	 [Step 5/38]     at kfun:systems.danger.DangerKotlin#run(){} (0x41c68f)
[12:19:09] :	 [Step 5/38]     at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b6f7)
[12:19:09] :	 [Step 5/38]     at Init_and_run_start (0x44c656)
[12:19:09] :	 [Step 5/38]     at __libc_start_main (0x7f2f5c7d00b3)
[12:19:09] :	 [Step 5/38]     at  (0x405031)
[12:19:09] :	 [Step 5/38]     at  ((nil))
[12:19:09] :	 [Step 5/38] 
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.640Z danger:runDangerSubprocess child process exited with code 1
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.640Z danger:runDangerSubprocess Handling fail from subprocess
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.641Z danger:jsonToDSL Creating pr DSL from JSON
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.641Z danger:BitBucketCloudGit Setting up git DSL with:  { repo: '#######/#######-android',
[12:19:09]W:	 [Step 5/38]   baseSHA: 'ea1e9509c44f',
[12:19:09]W:	 [Step 5/38]   headSHA: '08c6956ea197',
[12:19:09]W:	 [Step 5/38]   getFileContents: [Function],
[12:19:09]W:	 [Step 5/38]   getFullDiff: [Function] }
[12:19:09] :	 [Step 5/38] Failing the build, there is 1 fail.
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.642Z danger:executor Got results back: { warnings: [],
[12:19:09]W:	 [Step 5/38]   messages: [],
[12:19:09]W:	 [Step 5/38]   fails: [ { message: '`danger-kotlin` failed.' } ],
[12:19:09]W:	 [Step 5/38]   markdowns:
[12:19:09]W:	 [Step 5/38]    [ { message:
[12:19:09]W:	 [Step 5/38]         '### Log\n\n\n```sh\n\u001b[0;0mStarting Danger-Kotlin 1.1.0 with args \'runner, /usr/local/lib/node_modules/danger/distribution/commands/danger-ci.js, --process, danger-kotlin, --passURLForDSL\'\u001b[0;0m\n\u001b[0;0mGot Danger DSL path danger://dsl//opt/teamcity/temp/buildTmp/danger-dsl.json\u001b[0;0m\n\u001b[0;0mStripped DSL Path /opt/teamcity/temp/buildTmp/danger-dsl.json\u001b[0;0m\n\u001b[0;0mCompiling Dangerfile Dangerfile.df.kts\u001b[0;0m\n\u001b[0;0mExecuting kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json - pid 13136\u001b[0;0m\nUncaught Kotlin exception: kotlin.Exception: Command kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json exited with code 32512\n    at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)\n    at kfun:systems.danger.cmd.dangerfile.DangerFile#execute(kotlin.String;kotlin.String){} (0x41e271)\n    at kfun:systems.danger.DangerKotlin#run(){} (0x41c68f)\n    at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b6f7)\n    at Init_and_run_start (0x44c656)\n    at __libc_start_main (0x7f2f5c7d00b3)\n    at  (0x405031)\n    at  ((nil))\n\n```\n' } ] }
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.642Z danger:executor Evaluator settings { stdoutOnly: undefined,
[12:19:09]W:	 [Step 5/38]   verbose: undefined,
[12:19:09]W:	 [Step 5/38]   jsonOnly: undefined,
[12:19:09]W:	 [Step 5/38]   dangerID: 'Danger',
[12:19:09]W:	 [Step 5/38]   passURLForDSL: true,
[12:19:09]W:	 [Step 5/38]   disableGitHubChecksSupport: true,
[12:19:09]W:	 [Step 5/38]   failOnErrors: undefined,
[12:19:09]W:	 [Step 5/38]   noPublishCheck: false,
[12:19:09]W:	 [Step 5/38]   ignoreOutOfDiffComments: undefined,
[12:19:09]W:	 [Step 5/38]   newComment: false,
[12:19:09]W:	 [Step 5/38]   removePreviousComments: false }
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.643Z danger:executor Posting to platform: { warnings: [],
[12:19:09]W:	 [Step 5/38]   messages: [],
[12:19:09]W:	 [Step 5/38]   fails: [ { message: '`danger-kotlin` failed.' } ],
[12:19:09]W:	 [Step 5/38]   markdowns:
[12:19:09]W:	 [Step 5/38]    [ { message:
[12:19:09]W:	 [Step 5/38]         '### Log\n\n\n```sh\n\u001b[0;0mStarting Danger-Kotlin 1.1.0 with args \'runner, /usr/local/lib/node_modules/danger/distribution/commands/danger-ci.js, --process, danger-kotlin, --passURLForDSL\'\u001b[0;0m\n\u001b[0;0mGot Danger DSL path danger://dsl//opt/teamcity/temp/buildTmp/danger-dsl.json\u001b[0;0m\n\u001b[0;0mStripped DSL Path /opt/teamcity/temp/buildTmp/danger-dsl.json\u001b[0;0m\n\u001b[0;0mCompiling Dangerfile Dangerfile.df.kts\u001b[0;0m\n\u001b[0;0mExecuting kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json - pid 13136\u001b[0;0m\nUncaught Kotlin exception: kotlin.Exception: Command kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /opt/teamcity/temp/buildTmp/danger-dsl.json danger_out.json exited with code 32512\n    at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)\n    at kfun:systems.danger.cmd.dangerfile.DangerFile#execute(kotlin.String;kotlin.String){} (0x41e271)\n    at kfun:systems.danger.DangerKotlin#run(){} (0x41c68f)\n    at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b6f7)\n    at Init_and_run_start (0x44c656)\n    at __libc_start_main (0x7f2f5c7d00b3)\n    at  (0x405031)\n    at  ((nil))\n\n```\n' } ] }
[12:19:09]W:	 [Step 5/38] 2022-07-26T12:19:09.643Z danger:BitBucketCloudAPI GET https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715/comments?q=deleted=false
[12:19:10]W:	 [Step 5/38] 2022-07-26T12:19:10.163Z danger:BitBucketCloudAPI GET https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715/comments?q=deleted=false
[12:19:10]W:	 [Step 5/38] 2022-07-26T12:19:10.697Z danger:BitBucketCloudAPI POST https://api.bitbucket.org/2.0/repositories/#######/#######-android/pullrequests/30715/comments
[12:19:11] :	 [Step 5/38] Feedback: https://bitbucket.org/#######/#######-android/pull-requests/30715/_/diff#comment-318885151
[12:19:11]W:	 [Step 5/38] 2022-07-26T12:19:11.354Z danger:BitBucketCloudAPI POST https://api.bitbucket.org/2.0/repositories/#######/#######-android/commit/08c6956ea197/statuses/build
[12:19:11] :	 [Step 5/38] Uncaught Kotlin exception: kotlin.Exception: Command $(which danger) ci --process danger-kotlin --passURLForDSL  exited with code 256
[12:19:11] :	 [Step 5/38]     at kfun:systems.danger.cmd.Cmd.exec#internal (0x41d751)
[12:19:11] :	 [Step 5/38]     at kfun:systems.danger.cmd.dangerjs.DangerJS#process(systems.danger.cmd.Command;kotlin.String;kotlin.collections.List<kotlin.String>){} (0x41f2bb)
[12:19:11] :	 [Step 5/38]     at kfun:#main(kotlin.Array<kotlin.String>){} (0x41b95b)
[12:19:11] :	 [Step 5/38]     at Init_and_run_start (0x44c656)
[12:19:11] :	 [Step 5/38]     at __libc_start_main (0x7fa119f360b3)
[12:19:11] :	 [Step 5/38]     at  (0x405031)
[12:19:11] :	 [Step 5/38]     at  ((nil))
[12:19:11]W:	 [Step 5/38] Process exited with code 1
[12:20:49]E:	 [Step 5/38] Process exited with code 1 (Step: Danger Kotlin Install (Command Line))
[12:19:12]E:	 [Step 5/38] Step Danger Kotlin Install (Command Line) failed

@gianluz
Copy link
Member

gianluz commented Jul 27, 2022

seems like the problem is whiles running the step cannot find kotlinc at all that is strange because is installed as well together with danger-kotlin if not present.

you may want to try by adding the kotlinc path similarly to what you are doing with the kotlin home:

echo 'export KOTLINC_HOME=/path/to/kotlinc' >> ~/.bash_profile
echo 'export KOTLIN_HOME=/usr/local/bin/kotlin' >> ~/.bash_profile
echo 'export PATH=$PATH:$KOTLIN_HOME/bin:$KOTLINC_HOME/bin' >> ~/.bash_profile

or install kotlinc explicitly before danger-kotlin?

@vchernyshov
Copy link
Author

vchernyshov commented Jul 27, 2022

@gianluz will try, but not sure that it could help.
The possible reason of such error is that platform.posix.system under the hood creates a child process and maybe this child process requires it's own export of vars.

Have you tried to run danger kotlin with plugins on Ubuntu 20.04?

@vchernyshov
Copy link
Author

@gianluz is it possible to add plugin to docker image that you have for danger kotlin and run all under the docker? or the issues will be the same?

@gianluz
Copy link
Member

gianluz commented Jul 27, 2022

Is worth a try I think, you should be able to pull the working docker image and run danger from there, if works is also better than installing every time and should be faster as well

@gianluz
Copy link
Member

gianluz commented Jul 27, 2022

@gianluz will try, but not sure that it could help.
The possible reason of such error is that platform.posix.system under the hood creates a child process and maybe this child process requires it's own export of vars.

Have you tried to run danger kotlin with plugins on Ubuntu 20.04?

Yes but on bitrise and i haven't seen any issues.. Teamcity I've never tried before

@dunyakirkali
Copy link

I have the same issue on GitHub Actions.

My Dangerfile.df.kts

import systems.danger.kotlin.danger
import systems.danger.kotlin.onGitHub
import systems.danger.kotlin.pullRequest
import systems.danger.kotlin.warn

danger(args) {
    onGitHub {
        // Big PR Check
        if ((pullRequest.additions ?: 0) - (pullRequest.deletions ?: 0) > 300) {
            warn("Big PR, try to keep changes smaller if you can")
        }
    }
}

My ci.yaml

  danger:
    name: Danger
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2.4.0
      - name: Set up JDK 11
        uses: actions/setup-java@v2
        with:
          java-version: '11'
          distribution: 'adopt'
      - uses: fwilhe2/setup-kotlin@main
      - name: Danger
        uses: danger/kotlin@1.2.0
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

And the error I get is:

| Executing $(which danger) ci --process danger-kotlin --passURLForDSL  - pid 1
| Executing kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /tmp/danger-dsl.json danger_out.json - pid 23
|
| Uncaught Kotlin exception: kotlin.Exception: Command kotlinc -script-templates systems.danger.kts.DangerFileScript -cp /usr/local/lib/danger/danger-kotlin.jar -script Dangerfile.df.kts /tmp/danger-dsl.json danger_out.json exited with code 32512
|     at 0   danger-kotlin                       0x418785           kfun:systems.danger.cmd.Cmd.exec#internal + 1221
|     at 1   danger-kotlin                       0x4191e5           kfun:systems.danger.cmd.dangerfile.DangerFile#execute(kotlin.String;kotlin.String){} + 1189
|     at 2   danger-kotlin                       0x417ef4           kfun:systems.danger.DangerKotlin#run(){} + 2068
|     at 3   danger-kotlin                       0x41748c           kfun:#main(kotlin.Array<kotlin.String>){} + 2700
|     at 4   danger-kotlin                       0x4231a3           Init_and_run_start + 1811
|     at 5   danger-kotlin                       0x4232da           main + 10
|     at 6   libc.so.6                           0x7fd68c288d8f     0x0 + 140559451196815
|     at 7   libc.so.6                           0x7fd68c288e3f     __libc_start_main + 127
|     at 8   danger-kotlin                       0x405080           0x0 + 4214912
|
| sh: 1: kotlinc: not found
|
| Error:  Error: Got no results back from the Dangerfile evaluation, this is likely an issue with a custom sub-process exiting early.
|     at Executor.<anonymous> (/usr/lib/node_modules/danger/distribution/runner/Executor.js:152:35)
|     at step (/usr/lib/node_modules/danger/distribution/runner/Executor.js:33:23)
|     at Object.next (/usr/lib/node_modules/danger/distribution/runner/Executor.js:14:53)
|     at /usr/lib/node_modules/danger/distribution/runner/Executor.js:8:71
|     at new Promise (<anonymous>)
|     at __awaiter (/usr/lib/node_modules/danger/distribution/runner/Executor.js:4:12)
|     at Executor.handleResults (/usr/lib/node_modules/danger/distribution/runner/Executor.js:146:16)
|     at /usr/lib/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:172:47
|     at step (/usr/lib/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:44:23)
|     at Object.next (/usr/lib/node_modules/danger/distribution/commands/utils/runDangerSubprocess.js:25:53)
| Uncaught Kotlin exception: kotlin.Exception: Command $(which danger) ci --process danger-kotlin --passURLForDSL  exited with code 256
|     at 0   danger-kotlin                       0x418785           kfun:systems.danger.cmd.Cmd.exec#internal + 1221
|     at 1   danger-kotlin                       0x419fd8           kfun:systems.danger.cmd.dangerjs.DangerJS#process(systems.danger.cmd.Command;kotlin.String;kotlin.collections.List<kotlin.String>){} + 1336
|     at 2   danger-kotlin                       0x4170c6           kfun:#main(kotlin.Array<kotlin.String>){} + 1734
|     at 3   danger-kotlin                       0x4231a3           Init_and_run_start + 1811
|     at 4   danger-kotlin                       0x4232da           main + 10
|     at 5   libc.so.6                           0x7ff1924dbd8f     0x0 + 140675518414223
|     at 6   libc.so.6                           0x7ff1924dbe3f     __libc_start_main + 127
|     at 7   danger-kotlin                       0x405080           0x0 + 4214912

Any guidance would be greatly appreciated 😊

@Vacxe
Copy link
Member

Vacxe commented May 9, 2023

@dunyakirkali did you have any chance to resolve this issue?

Have pretty much the same

[14:33:37 ]Executing $(which danger) ci --process danger-kotlin --passURLForDSL  - pid 10
[14:33:37 ] ci --process danger-kotlin --passURLForDSL  exited with code 32512
[14:33:37 ]  at 0   danger-kotlin                       0x418785           kfun:systems.danger.cmd.Cmd.exec#internal + 1221
[14:33:37 ]{} + 1336
[14:33:37 ]{} + 1734
[14:33:37 ]    at 3   danger-kotlin                       0x4231a3           Init_and_run_start + 1811
[14:33:37 ]    at 4   danger-kotlin                       0x4232da           main + 10
[14:33:37 ]    at 5   libc.so.6                           0x7f592a1c4d8f     0x0 + 140020935314831
[14:33:37 ]    at 6   libc.so.6                           0x7f592a1c4e3f     __libc_start_main + 127
[14:33:37 ]    at 7   danger-kotlin                       0x405080           0x0 + 4214912
[14:33:37 ] /mnt/app/temp/agentTmp/custom_script8683790755446500615: line 12:    10 Aborted                 (core dumped) danger-kotlin ci

CI: Teamcity
Run in Docker
Version 1.2.0

@gianluz
Copy link
Member

gianluz commented May 11, 2023

definitely something is not going right with the dependencies, please try to install manually the kotlin compiler before installing danger kotlin in your CI

curl -o kotlin-compiler.zip -L https://github.com/JetBrains/kotlin/releases/download/v1.7.0/kotlin-compiler-1.7.0.zip
unzip -d /usr/local/ kotlin-compiler.zip
echo 'export PATH=/usr/local/kotlinc/bin:$PATH' >> ~/.bash_profile
rm -rf kotlin-compiler.zip

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

4 participants