Post not yet marked as solved
We have been trying to understand why the Mac OS Terminal, when invoked with open, does not pass along the environment variables.
How to reproduce?
Create a new file /tmp/example.sh
#!/bin/sh
echo "SAMPLE_ENV='$SAMPLE_ENV'"
SAMPLE_ENV=123 open -a Terminal /tmp/example.command
Only prints: SAMPLE_ENV=''
Even when using
SAMPLE_ENV=123 open --env SAMPLE_ENV=1234 -a Terminal /tmp/example.sh
it will only print SAMPLE_ENV=''
We know for sure that this was working several years ago. Why was the feature removed or is this a bug?
Any workaround?
Is there a workaround on how to launch a script in a new Terminal Window while passing the environment variables correctly?
Related
https://stackoverflow.com/questions/69768133/react-native-envs-are-undefined-in-metro-bundlers-config-file-when-bundling/73036234
Post not yet marked as solved
I have a command line tool that zsh refuses to run when built for Apple Silicon or as a univerisal binary (the specific message is zsh: killed TOOL_NAME). I can only get it to run if I build it exclusively for Intel/Rosetta.
Running/debugging from within Xcode works fine for any architecture.
The tool is a very simple C/C++ unix command-line tool; it doesn't have any external dependencies beyond the C runtime and the C++ STL.
I suspect something in code signing is going awry, but I've tried various team and certificate combinations without any luck. I've also tried enabling/disabling the app sandbox, also without any luck. (The app is not for distribution so it doesn't really need to be code signed at all.)
Any suggestions?
Post not yet marked as solved
Hello everyone. The project I am working on is shifting from using CocoaPods to SPM and there is one "wrinkle" I'd like some advice on. The project has several framework projects containing code as well as the main app project. All of these make use of code generators (RSwift, Sourcery) at some point and these need to be run before the main build starts.
The problem is that SPM builds do not support the concept of adding script phases so there appears to be no easy way to incorporate these shell tools into the builds. Particularly in the framework projects which are pure SPM packages and therefore do not have your typical project files and build phases.
My question is - how to deal with shell based build phases in an SPM world?
Currently we are adding these phases in the main app's build. However they are not run before the builds of the SPM dependencies so effectively we have to run the build twice to ensure the code is up to date.
Post not yet marked as solved
I am trying to open Facebook Messenger on my app. It opens so far as I can see my contacts, but before I can see my messages it closes. Then Terminal gives me this message:
Last login: Fri Dec 3 08:49:11 on ttys001
/Applications/Messenger.app/Contents/MacOS/Messenger ; exit;
[myusername]@iMac ~ % /Applications/Messenger.app/Contents/MacOS/Messenger ; exit;
zsh: abort /Applications/Messenger.app/Contents/MacOS/Messenger
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[Process completed]
Any suggestions how to open this app.
Working with a M1 Macbook Air, macos 12.4.
Anytime I open a new terminal window or just a new tab, it takes a really long time till I can type.
I have commented out my entire ~/.zshrc and when run
for i in $(seq 1 10); do /usr/bin/time $SHELL -i -c exit; done
directly in an open terminal window it says it finished in 0.1s.
So it must be something macos is doing before zsh is even starting.
PS: In the activity monitor I can only see a spike in kernel_task cpu usage when opening a new terminal
Post not yet marked as solved
Not really a "developer" question per se, but related to the Xcode developer tools as run on a new M1 Mac running Monterey (12.1).
When running various tools, such as "opendiff" I receive the following error reported on stderr:
objc[6599]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libauthinstall.dylib (0x1e30deb90) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108f7c2c8). One of the two will be used. Which one is undefined.
objc[6599]: Class AMSupportURLSession is implemented in both /usr/lib/libauthinstall.dylib (0x1e30debe0) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/Versions/A/MobileDevice (0x108f7c318). One of the two will be used. Which one is undefined.
I'm working on the assumption that two conflicting libraries have been installed that provide a definition for the same symbol, and (since the opendiff program loads and runs) that at least for now, both symbols are defined in a similar enough way that whichever one is actually loaded works.
I was at first very confused because there is actually no file on my system with the name /usr/lib/libauthinstall.dylib
While this makes the error message rather confusing, I found this thread https://developer.apple.com/forums/thread/692383 that makes clear that many of the files in /usr/lib in an earlier part of the release process are amalgamated, and I assume that libauthinstall.dylib is one of these files.
Given that this implies that the /usr/lib versions are likely the "more authoritative" versions, I am not actually sure why the directory /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework even exists -- I don't do any mobile development on this machine, so I assume that it came out of the setup, or possible from a migration of the user content from a machine running BigSur (content transferred using TimeMachine).
Does anyone have any ideas regarding:
(a) how this came about (as it appears that both sources are installed by Apple), and
(b) how I can remove the conflict.
I'm using opendiff in a project workflow and really don't want to see the workflow polluted with spurious error messages, not to mention the fragility of not being able to control which symbol these tools are actually using.
Thanks in advance for any thoughts.
EDIT: There are a number of posts around the 'net linking this error with "homebrew". I believe that this is at least partially a red herring, because:
a) I don't use homebrew (though I do use MacPorts) -- I avoid hombrew largely because of its plan to play in /usr while MacPorts keeps everything well out of the way in /opt
b) both of the named sources are from Apple.
Post not yet marked as solved
Hi Guys,
I am using the new Apple M1 Max and macOS Monterey, I am trying to install cocoa pod but getting errors like below. I tried to fix it with help of StackOverflow and many ways but no luck. Please help to resolve this issue.
ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory.
Post not yet marked as solved
I need to create a script for checking a security posture of a
machine using OPSWAT MetaAccess. They have a built-in check, however,
according to them, they aren't able to check since macOS 10.13+. This
seems to coordinate with a change other people have discussed on other
forums where the following commands don't work anymore. OPSWAT does
support checks via custom shell script and so I'm figuring out how to
write that now.
The scripts that don't work anymore:
defaults read com.apple.screensaver idleTime
defaults -currentHost read com.apple.screensaver idleTime
defaults -currentHost read com.apple.screensaver askForPassword
defaults read com.apple.screensaver askForPassword
Post not yet marked as solved
We have a problem with curl. Under Big Sur, the command
curl 'ftp://ftp.myserver/myPath/my File' -u 'myusername':'mypassword'
properly downloads the file.
Under Monterey, the same command throws an error:
curl: (3) URL using bad/illegal format or missing URL
Any advice, workaround etc. is highly appreciated.
The behaviour is the same, whether the command is issued in Terminal, or as a shell script in a Applescript application created in XCode.
Post not yet marked as solved
I have postgresql app download to Mac - Im worrking in zsh shell. Created a rails new - went to db:create or migrate &bit wont let me.
now my error is
ERROR: While executing gem ... (Gem::FilePermissionError)
"You dont have permissions for /Library/Ruby/Gems/2.6.0 directory.
Post not yet marked as solved
When i compile the c program with mysql i get the next error:
ld: library not found for -lzstd
clang: error: linker command failed with exit code 1 (use -v to see invocation)
So i use the zstd (that i installed) directory link in my command line
gcc parking.o -o parking.exe `mysql_config --libs` -L/opt/homebrew/Cellar/zstd/1.5.2/lib
It creates the .exe but when i launch it i get
How can i solve it ? Need help please.
Post not yet marked as solved
I had a number of paths, aliases, customizations and such in my ZSH profile, but I opened up Terminal, today, and now the only thing in it is a path for SDKMAN.
how could this have happened?
can I restore my profile?
Post not yet marked as solved
Whenever I am trying to run the command "dsconfigad -show", it is not returning anything. But I can see that I am connected to a domain in "enterprise connect". My Mac version is Monterey(version 12.2). Can anyone solve this issue. Thanks in advance.
Post not yet marked as solved
Can we write batch scripts to configure permissions and system preferences for multiple apps on MacOS devices.
Post not yet marked as solved
I have some shell scripts that are needed to run on the Build Phase of my iOS App, but all of then keeps getting killed when trying to run.
For example with SwiftLint:
/Users/vinicius/Library/Developer/Xcode/DerivedData/MyProject-somerandomstuff/Build/Intermediates.noindex/MyProject.build/Debug-iphonesimulator/MyProject.build/Script-BE4377BE84BF95B2A0F6A35B.sh: line 2: 44634 Killed: 9 "${PODS_ROOT}/SwiftLint/swiftlint" autocorrect
I was thinking that could be related to some lack of permission, but I can't really identify if it really is, since it's executing the files.
Do you have any idea?
Post not yet marked as solved
I've just bought a new MacBook Pro M1, and restored everything from my old Intel MacBook Pro using a Time Machine backup.
It was a pretty smooth process, a few glitches such as needing to re-download certain apps to get the M1 version (e.g. Android Studio).
One thing that I've noticed, and I don't know whether this is a Monterey thing or an M1 thing but as part of my day-to-day development work, I maintain various .sh files for building projects on different platforms.
I have found that as soon as I edit and save an existing .sh file using TextEdit, it then sets the quarantine bit on the file and prevents it running from inside Zsh:
zsh: operation not permitted: ./test.sh
xattr yields the following:
xattr ./test.sh
com.apple.TextEncoding
com.apple.lastuseddate#PS
com.apple.macl
com.apple.metadata:kMDLabel_pjtfm5adga5rvjv2xmgkyqjwmq
com.apple.quarantine
This is incredibly annoying and I can't believe it is by design - this is not a file that has been downloaded from the Internet, it's my own file. Why can't I edit it using TextEdit?
I do not get the same problem when I edit and save using Sublime Text, as one example, so what's with TextEdit doing that?
Post not yet marked as solved
Machine - MacBook Pro 13 with Apple M1 chip
Hi team,
Just wanted to get some help in sorting Ahoy installation on new MacBook Pro 13 with Apple M1 chip.
I ran "brew install ahoy" but got a message saying "bottle not available"
I have been able to build it from source and as per log below, it seems to have installed.
But when I run any commands, I am getting a "zsh: segmentation fault ahoy help" error and unable to run any ahoy commands.
NOTE: MacBook CONSOLE LOG added below.
CONSOLE ERROR LOG -
++++++++++++++++++++++++++++++++++++++++
Process: ahoy [1840]
Path: /opt/homebrew/*/ahoy
Identifier: ahoy
Version: ???
Code Type: X86-64 (Translated)
Parent Process: zsh [1748]
Responsible: Terminal [1746]
User ID: 501
Date/Time: 2021-02-15 12:23:20.982 +1100
OS Version: macOS 11.2.1 (20D74)
Report Version: 12
Anonymous UUID: D7AF3B6F-CFAB-F9ED-0E45-DC1AD1784827
Sleep/Wake UUID: 1689D6DE-2DD8-496C-AAC6-A6BE6699BBE9
Time Awake Since Boot: 6300 seconds
Time Since Wake: 1500 seconds
System Integrity Protection: enabled
Crashed Thread: 0
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000018
Exception Note: EXC_CORPSE_NOTIFY
Termination Signal: Segmentation fault: 11
Termination Reason: Namespace SIGNAL, Code 0xb
Terminating Process: exc handler [1840]
VM Regions Near 0x18:-
__TEXT 1000000-125f000 [ 2428K] r-x/rwx SM=COW
Application Specific Information:
dyld2 mode
Thread 0 Crashed:
0 runtime 0x00007ffdfff70bb0 0x7ffdfff5f000 + 72624
1 0x00000000010518fd runtime.bsdthread_register + 29
2 0x00000000010295d1 runtime.schedinit + 161
Thread 1:: com.apple.rosetta.exceptionserver
0 runtime 0x00007ffdfff61238 0x7ffdfff5f000 + 8760
1 runtime 0x00007ffdfff6b354 0x7ffdfff5f000 + 50004
2 runtime 0x00007ffdfff6c1f8 0x7ffdfff5f000 + 53752
Thread 0 crashed with ARM Thread State (64-bit):
x0: 0x800000010000fb90 x1: 0x00000000010518a0 x2: 0x0000000000000000 x3: 0x0000000000000000
x4: 0x0000000000000000 x5: 0x0000000000000000 x6: 0x0000000000000000 x7: 0x000000c42000a020
x8: 0x00007ffdfffd4a00 x9: 0x00007ffdfffd4a08 x10: 0x0000000000000000 x11: 0x00000000ffffffff
x12: 0x0000000000000000 x13: 0x00000000ffffffee x14: 0x0000000000000140 x15: 0x0000000000000100
x16: 0x000000000000016e x17: 0x0000000000000000 x18: 0x800000010000fb90 x19: 0x0000000100000000
x20: 0x00000000000007ff x21: 0x0000000100014fc0 x22: 0x00000002055eaac8 x23: 0x000000000150e224
x24: 0x00000000010243b0 x25: 0x00000000013022d0 x26: 0x00000000012f8cd8 x27: 0x0000000000000000
x28: 0x00000000010518fd fp: 0x00007ffdfff70b98 lr: 0x000000000150e254
sp: 0x000000010000fb90 pc: 0x00007ffdfff70bb0 cpsr: 0x80000000
far: 0x0000000000000018 esr: 0x92000006
Binary Images:
0x1000000 - 0x125efff + (???)
0x1014d3000 - 0x10156efff dyld (832.7.3) 0D4EA85F-7E30-338B-9215-314A5A5539B6 /usr/lib/dyld
0x7ffdfff5f000 - 0x7ffdfffd2fff +runtime (203.30) C98E75A6-BDC8-3D5C-B95B-6422005E96D8 /Library/Apple/*/runtime
External Modification Summary:
Calls made by other processes targeting this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by this process:
task_for_pid: 0
thread_create: 0
thread_set_state: 0
Calls made by all processes on this machine:
task_for_pid: 4298
thread_create: 0
thread_set_state: 0
VM Region Summary:
ReadOnly portion of Libraries: Total=3972K resident=0K(0%) swapped_out_or_unallocated=3972K(100%)
Writable regions: Total=150.7M written=0K(0%) resident=0K(0%) swapped_out=0K(0%) unallocated=150.7M(100%) VIRTUAL REGION
REGION TYPE SIZE COUNT (non-coalesced)
=========== ======= =======
Rosetta Arena 2048K 1
Rosetta Generic 584K 143
Rosetta IndirectBranch 32K 1
Rosetta JIT 128.0M 1
Rosetta Return Stack 20K 2
Rosetta Thread Context 20K 2
VM_ALLOCATE 528.5G 9
VM_ALLOCATE (reserved) 8K 2 reserved VM address space (unallocated)
__DATA 488K 6
__DATA_CONST 32K 1
__LINKEDIT 492K 5
__TEXT 3516K 3
mapped file 4.7G 12
=========== ======= =======
TOTAL 533.3G 188
TOTAL, minus reserved VM space 533.3G 188
Post not yet marked as solved
Paths in /etc/paths.d are not expanded for all shells.
dotnet adds a /etc/paths.d/dotnet-cli-tools file that contains
~/.dotnet/tools
The ~/.dotnet/tools folder is used for tools that are 'global' across all projects for the same user.
The tilde is not expanded for zsh and executables installed to ~/.dotnet/tools will not be found via the PATH. $HOME/dotnet/tools is also not expanded. (There appears to be a difference with bash. bash does seem to expand the tilde but doesn't expand variables.)
The man page for path_helper says
Files in these directories should contain one path element per line.
The /etc/paths.d mechanism is great. Keeping installers out of a user's .profile/.zprofile/.zshrc/etc files is very helpful. But user home directory paths for the current user are not supported (at least not consistently across all shells) in the current implementation of path_helper and paths.d.
Not expanding paths might be by design or by omission but adding support for paths in the current user home would be useful.
Post not yet marked as solved
Hi!
I am new to OSX Shell Script and am trying to work my way into it. I don't get the expected outcome with the following snippet of my script code and I have no idea, why. I read most of the Apple Shell Script Pimer and googled a lot about it, but to no avail.
I want to check the current username against some given usernames and set the value of a variable depending on the outcome. I used awk inside the shell script to get this done, but for some reason the for loop inside the awk part seems to change the value of the current username with every loop.
This is the code:
#!/bin/zsh
awk -v u=$USER 'BEGIN {
print "Username outside loop is " u;
count[0] = "Anton";
count[1] = "Bert";
count[2] = "Carl";
for ( c_num in count ) {
print "Username inside loop is " u;
print "Compare to "count[c_num];
if (u = count[c_num]) {
test_var = "X";
} else {
test_var = "Y";
}
print test_var;
}
}'
And this is what I get after I run it in terminal:
Username outside loop is Zac
Username inside loop is Zac
Compare to Carl
X
Username inside loop is Carl
Compare to Anton
X
Username inside loop is Anton
Compare to Bert
X
I don't see why 'u' is changed every loop.
I'm thankful for every help / advice!
Markus
Post not yet marked as solved
Script Example:
sudo dscl . -create /Users/ITAdmin
sudo dscl . -create /Users/ITAdmin UserShell /bin/bash
sudo dscl . -create /Users/ITAdmin RealName ITAdmin
sudo dscl . -create /Users/ITAdmin UniqueID 502
sudo dscl . -create /Users/ITAdmin PrimaryGroupID 20
sudo dscl . -create /Users/ITAdmin NFSHomeDirectory /Local/Users/ITAdmin
sudo dscl . -create /Users/ITAdmin NFSHomeDirectory /Users/[ITuser]
sudo dscl . -passwd /Users/ITAdmin [password]
sudo dscl . -append /Groups/admin GroupMembership ITAdmin
When using this locally or remotely, it works except the Home folder does not create or show up in the UI. After further testing, it does show up after an initial first time login. With our remote workforce and the secondary reasons for needing this script, we're trying to find a way to mimic a user login to add into our actual other script so that the home folder is created without actual end user interaction (won't be possible.)
Or are there any other alternative ways to script a new admin user account?
(Or a better place to ask this?)
Thanks in advanced!