Author Topic: [MacOSX 10.15][svn-r12240]zsh: no such file or directory  (Read 1703 times)

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
[MacOSX 10.15][svn-r12240]zsh: no such file or directory
« on: December 31, 2020, 12:14:43 am »
I have see the same problem on other thread and other web site .


When i launch terminal application from CB i have this message:
[…] zsh: no such file or directory […]

Code
➜  ~ zsh --version
zsh 5.8 (x86_64-apple-darwin19.6.0)

I have try this solutions:
 
https://sourabhbajaj.com/mac-setup/iTerm/zsh.html

or

https://technobyte.org/install-code-blocks-on-mac-os-gcc-compiler/  (watch the comments)
```
sudo sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
chsh -s /bin/zsh
source ~/.zhrc
```

Here the other topics:
http://forums.codeblocks.org/index.php/topic,23357.msg159018.html#msg159018
http://forums.codeblocks.org/index.php/topic,18907.msg129527.html#msg129527


I continue my investigation. :p



Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #1 on: December 31, 2020, 01:26:30 am »
With Codelite with a simple «Hello World» project work.

Here the terminal how is calling:

Code
/Applications/codelite.app/Contents/MacOS/osx-terminal.sh "cd /Users/toto/folder/Test_CL_Mac/Debug && ./Test_Terminal\ "
The code of osx-terminal.sh file is:
Code
#!/bin/sh

echo '
on run argv
  if length of argv is equal to 0
    set command to ""
  else
    set command to item 1 of argv
  end if

  if length of argv is greater than 1
    set profile to item 2 of argv
    runWithProfile(command, profile)
  else
    runSimple(command)
  end if
end run

on runSimple(command)
  tell application "Terminal"
    activate
    set newTab to do script(command)
  end tell
  return newTab
end runSimple

on runWithProfile(command, profile)
  set newTab to runSimple(command)
  tell application "Terminal" to set current settings of newTab to (first settings set whose name is profile)
end runWithProfile
' | osascript - "[email protected]" > /dev/null

The command to call a terminal application with CB is here:
Code
osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script quoted form of "$SCRIPT"' -e 'end tell'
Example:
Code
osascript -e 'tell app "Terminal"' -e 'activate' -e 'do script quoted form of "/Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=:. /.../Test_App/bin/Debug/Test_App "' -e 'end tell'  (in /.../Test_App/.)

On CB Linux the command with xterm is :
Code
xterm -T $TITLE -e
Example:
Code
Checking for existence: /directory/APP/bin/Debug/APP
Set variable: LD_LIBRARY_PATH=.:/some/paths
Executing: xterm -T APP -e /path/CodeBlocks/bin/cb_console_runner LD_LIBRARY_PATH=:.:/some/paths /directory/APP/bin/Debug/APP -e "some arguments" (in /directory/APP/.)

« Last Edit: December 31, 2020, 02:20:55 am by Suryavarman »

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #2 on: December 31, 2020, 02:55:40 am »
Like that C::B launch the application (doesn't work very well in debug : I use /usr/local/Cellar/gdb/10.1/bin/gdb).
Code
/Applications/codelite.app/Contents/MacOS/osx-terminal.sh "$SCRIPT"'

solution:
create osx-terminal.sh file where you want (YOUR_DIRECTORY).
put this code inside:

(The code come from https://codelite.org/)
Code
#!/bin/sh

echo '
on run argv
  if length of argv is equal to 0
    set command to ""
  else
    set command to item 1 of argv
  end if

  if length of argv is greater than 1
    set profile to item 2 of argv
    runWithProfile(command, profile)
  else
    runSimple(command)
  end if
end run

on runSimple(command)
  tell application "Terminal"
    activate
    set newTab to do script(command)
  end tell
  return newTab
end runSimple

on runWithProfile(command, profile)
  set newTab to runSimple(command)
  tell application "Terminal" to set current settings of newTab to (first settings set whose name is profile)
end runWithProfile
' | osascript - "[email protected]" > /dev/null

Save it.

Got to Codeblocks > Settings > Environment… > rescale the window on the bottom to see the field: Terminal to launch programs:
Replace the text by:
/YOUR_DIRECTORY/osx-terminal.sh "$SCRIPT"'
« Last Edit: December 31, 2020, 03:08:50 am by Suryavarman »

Offline omlk

  • Multiple posting newcomer
  • *
  • Posts: 50
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #3 on: December 31, 2020, 08:09:32 pm »
You have set up an environment in MacOS? And I no use MacOS - maybe need restart OS after set environment PATH where you install zsh.  Replase in_this_folder_instaled_zsh into path to zsh
Code
# Add commonly used folders to $PATH export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:in_this_folder_instaled_zsh"
« Last Edit: December 31, 2020, 08:11:32 pm by omlk »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13226
    • Travis build status
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #4 on: January 01, 2021, 12:40:43 pm »
@omlk: You have no idea what you're talking about...

@Suryavarman:
I've tried it and it kind of works, but not good enough.
Problems:
1. The terminal doesn't close itself automatically after the executable ends.
2. I couldn't make the gdb to run. Some code signing issues. Are you able to debug using this wrapper script?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #5 on: January 01, 2021, 06:02:05 pm »
Quote
Are you able to debug using this wrapper script?
Nop. There are no stack and the breaking points don't work. All it's like you said.

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #6 on: January 01, 2021, 08:01:01 pm »
The new version of Codelite use a new way and the debug works now:
They do that:
To launch a terminal without debuguing they call a temporary .sh file.

open -n -a Terminal /tmp/codelite-exec.sh
the terminal is calling with this arguments => /tmp/codelite-exec.sh ; exit;
Code
#!/bin/bash
command="/[…]/Test_CL_Mac/Debug/Test_Terminal"
cd /[…]/Test_CL_Mac/Debug && ${command}
echo Hit any key to continue...
read

To launch a terminal with debuguing they call another temporary .sh file.
the terminal is calling with this arguments => /tmp/codelite-lldb-helper.sh ; exit;
Code
#!/bin/bash
tty > /tmp/terminal.tty.11395
sleep 12345

------

With VSCode:

It's funny if you follow the tutorial of VSCode with Cland MacOS :
https://code.visualstudio.com/docs/cpp/config-clang-mac
They are a similar problem... MacOs Macos…
Code
code .
zsh: command not found: code

------

I continue to investigate.
« Last Edit: January 01, 2021, 11:18:08 pm by Suryavarman »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13226
    • Travis build status
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #7 on: January 01, 2021, 08:02:17 pm »
Do you have a working gdb? I'm not able to codesign mine on Catalina. :(
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #8 on: January 01, 2021, 11:15:02 pm »
I use the brew gdb(s) and i work on Catalina too.

/usr/local/Cellar/gdb/8.0.1/bin/gdb
/usr/local/Cellar/gdb/10.1/bin/gdb

brew install gdb

I haven't try to use them directly in command line.
But the 8.0.1 and 10.1 works with Codelite.
With Codeblocks the gdb path seem to be correct, the only problem come from the terminal execution.

With XCode it's work but i don't know witch gdb is set.

I'm not motivate to test VCode because i have to create manually all the configuration file.

Code
    tasks.json (compiler build settings)
    launch.json (debugger settings)
    c_cpp_properties.json (compiler path and IntelliSense settings)



« Last Edit: January 01, 2021, 11:19:57 pm by Suryavarman »

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #9 on: January 01, 2021, 11:51:34 pm »
You can also try with the default llvm debugger:
/usr/bin/lldb
Code
/usr/bin/lldb -v
lldb-1200.0.44.2
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #10 on: January 02, 2021, 12:13:47 am »
Ooo now i understand the meaning of what you have say Codesigned

https://stackoverflow.com/questions/13913818/how-to-get-a-codesigned-gdb-on-osx
https://stackoverflow.com/questions/18423124/please-check-gdb-is-codesigned-see-taskgated8-how-to-get-gdb-installed-w

 I have not anymore codesign problem with gdb:
 
Code
codesign -fs gdb-cert /usr/local/bin/gdb
codesign -fs gdb-cert "/usr/local/Cellar/gdb/10.1/bin/gdb"

Code
/dev/??: No such file or directory.

May be that can help:

codesign --entitlements gdb.xml -fs gdb-cert /usr/local/bin/gdb

Where content of gdb.xml is:

Code
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.cs.allow-jit</key>
    <true/>
    <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
    <true/>
    <key>com.apple.security.cs.allow-dyld-environment-variables</key>
    <true/>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.cs.disable-executable-page-protection</key>
    <true/>
    <key>com.apple.security.cs.debugger</key>
    <true/>
    <key>com.apple.security.get-task-allow</key>
    <true/>
</dict>
</plist>


But it's not enough to work with gdb : The errors are:

Code
Termination notification request failed, mach_port_request_notification

Code
Using sleep command’s PID as console PID 3088

[debug]> set confirm off

Debugger name and version: GNU gdb (GDB) 10.1

[debug]>>>>>>cb_gdb:
[debug]> set width 0
[debug]>>>>>>cb_gdb:
[debug]> set height 0
[debug]>>>>>>cb_gdb:
[debug]> set breakpoint pending on
[debug]>>>>>>cb_gdb:
[debug]> set print asm-demangle on
[debug]>>>>>>cb_gdb:
[debug]> set unwindonsignal on
[debug]>>>>>>cb_gdb:
[debug]> set print elements 200
[debug]>>>>>>cb_gdb:
[debug]> set filename-display absolute
[debug]>>>>>>cb_gdb:
[debug]> set disassembly-flavor intel
[debug]>>>>>>cb_gdb:
[debug]> catch throw
[debug]Catchpoint 1 (throw)
[debug]>>>>>>cb_gdb:
[debug]> directory /…/Test_App/
[debug]Source directories searched: /…/Test_App:$cdir:$cwd
[debug]>>>>>>cb_gdb:
[debug]> tty /dev/??
[debug]>>>>>>cb_gdb:
[debug]> run
[debug]/dev/??: No such file or directory.
[debug]Starting program: /…/Test_App/bin/Debug/Test_App
[debug]Termination notification request failed, mach_port_request_notification
[debug]returned: 4
[debug]>>>>>>cb_gdb:

i can't stop the gdb.

Code
Trying to interrupt process with pid: 3084; child pid: 0 gdb pid: 3084

[debug]Quit
[debug]>>>>>>cb_gdb:

The pid of the gdb and the PID of the console is 3088.
« Last Edit: January 02, 2021, 03:55:07 am by Suryavarman »

Offline Suryavarman

  • Multiple posting newcomer
  • *
  • Posts: 80
    • Suryavarman
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #11 on: January 02, 2021, 03:48:45 am »
I have say something wrong. Codelite do not use GDB. Codelite seem to use only lldb and not the custom paths to use GDB.

Lot's of people say to use lldb becouse lldb have no certifaciton/codesign problems.

Here the error with lldb and CB.
Code
ctive debugger config: GDB/CDB debugger:Default
Building to ensure sources are up-to-date
Selecting target:
Debug
Adding source dir: /.../Test_App/
Adding source dir: /.../Test_App/
Adding file: /.../Test_App/bin/Debug/Test_App
Changing directory to: /.../Test_App/.
Set variable: DYLD_LIBRARY_PATH=.:

[debug]Command-line: /usr/bin/lldb -fullname -quiet  -args /.../Test_App/bin/Debug/Test_App
[debug]Working dir : /.../Test_App

Starting debugger: /usr/bin/lldb -fullname -quiet  -args /.../Test_App/bin/Debug/Test_App
Setting SHELL to ‘/bin/sh’
done

[debug](lldb) target create « /.../Test_App/bin/Debug/Test_App »
[debug]> set prompt >>>>>>cb_gdb:

Setting breakpoints

[debug]invalid command ‘settings prompt’.
[debug]Current executable set to ‘/.../Test_App/bin/Debug/Test_App’ (x86_64).
[debug](lldb) set prompt >>>>>>cb_gdb:
[debug]> show version
[debug]error: ‘show’ is not a valid command.
[debug](lldb) show version
[debug]Using terminal’s PID as console PID 3842, TTY /dev/??
[debug]Queued:[tty /dev/??]

I think we are no choice we have to modify the CB code to add the gestion of lldb?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13226
    • Travis build status
Re: [MacOSX 10.15][svn-r12240]zsh: no such file or directory
« Reply #12 on: January 02, 2021, 01:40:14 pm »
This is partly true. In the long run we'll have to port to lldb, but this would require a separate debugger plugin. Hopefully I'll be able to do this in the first half of 2021...

This is the ultimate guide to codesign gdb: https://sourceware.org/gdb/wiki/PermissionsDarwin I don't know why search engines don't find it, but lead to some old interpretations of this. :(
With this I'm able to debug in a terminal, unfortunately C::B doesn't know how to handle the terminal and ttys.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]