Does Mac X11 have the XTEST extension? - macos

So I moved some X programs down to the mac, and I'm getting
Error: XTEST extension unavailable on '(null)'.
from xdotool.
Does OS X X11 come with XTEST?
If not, is there a way to add it?

Run the following command in the Terminal:
defaults write org.x.X11 enable_test_extensions -boolean true
(as per here). Then quit and restart the X server; the XTEST extension should then be available.

I had to do the following two commands to get this to work on Mountain Lion (from here):
defaults write org.x.X11 enable_test_extensions -boolean true
defaults write org.macosforge.xquartz.X11 enable_test_extensions -boolean true

For XQuartz,
defaults write org.macosforge.xquartz.X11 enable_test_extensions -bool yes
See this link.

Mac has test extension as part of the open source XQuartz project (if installed).
The X11.app was available by default for Mac OS X v10.5-10.7, but since Mountain Lion, Apple dropped dedicated support for X11.app, with users directed to the open source XQuartz project (to which it contributes) instead.
To test if the TEST extension is enabled, try the following commands:
$ defaults read org.x.X11
{
"enable_test_extensions" = 1;
}
$ defaults read org.macosforge.xquartz.X11
{
...
"enable_test_extensions" = 1;
"startx_script" = "/opt/X11/bin/startx -- /opt/X11/bin/Xquartz";
}
For downloading instructions, check XQuartz page.

Related

OSX fix Selenium Chromedriver launch error spawn Unknown system error -86 Bad CPU type in executable?

Suddenly on the afternoon of January 6, 2021, my Selenium Protractor tests under OSX stopped working with the mysterious error
spawn Unknown system error -86
I did some research and discovered that error number 86 is the same as
Bad CPU type in executable
and ran the following to compare the cpu architecture of my chromedriver binary to my system:
% file chromedriver_87.0.4280.88
chromedriver_87.0.4280.88: Mach-O 64-bit executable arm64
% uname -a
Darwin kobl179273m 19.6.0 Darwin Kernel Version 19.6.0: Thu Oct 29 22:56:45 PDT 2020; root:xnu-6153.141.2.2~1/RELEASE_X86_64 x86_64
% uname -p
i386
How can I fix the chromedriver binary used by my Selenium so that it will run on my Intel x64 mac and clear the "system error -86" or "Bad CPU type" message?
The issue is described in https://github.com/angular/webdriver-manager/issues/476.
This has been now fixed in 12.1.8 so just update to that webdriver manager.
For most users this can be accomplished with
npm uninstall protractor && npm install protractor
Edit: this answer should be considered deprecated now that the underlying bug in webdriver-manager has been fixed. A better solution would be to upgrade to the newest version of webdriver-manager. The answer below may be useful if people need to use an older version of webdriver-manager which still has the bug.
As per Deepak Srinivasan's comment above, this error is caused by https://github.com/angular/webdriver-manager/issues/476
Root Cause:
The ChromeDriver team added "_m1" to the end of the filename for their Apple Silicon ARM builds of Chromedriver -- but both the Silicon and Intel versions of chromedriver have "mac64" in the filename, and the version number is exactly the same. This causes webdriver-manager to always download the Silicon build of Chromedriver, even on Intel macs. As a general solution, simply avoid using the chromedriver that has _m1 in its filename if you are on an Intel mac.
Solution 1: Downgrade to Chrome 86.0.4240.198 and Chromedriver 86.0.4240.22. These versions work together and are the most recent versions prior to the new and problematic support for Silicon ARM
Chrome 86 download page:
https://google-chrome.en.uptodown.com/mac/download/2920124
Disable auto-updates in Chrome: https://superuser.com/questions/1359017/how-do-i-disable-automatic-updates-of-google-chrome-on-mac-os-x
Chromedriver 86: https://chromedriver.storage.googleapis.com/index.html?path=86.0.4240.22/
% webdriver-manager update --versions.chrome=86.0.4240.22
Solution 2: Modify the webdriver-manager npm package to point to the correct chromedriver (thanks to ciekaway from the angular github issue page for this fix)
Modify the following file
node_modules/webdriver-manager/built/lib/files/file_manager.js
or, if using protractor
node_modules/protractor/node_modules/webdriver-manager/built/lib/files/file_manager.js
Near the top of the downloadFile method around line 166, add the following line to remove "_m1" from the name of the file:
fileUrl.url = fileUrl.url.replace(/_m1/, '');
It needs to be after the beginning of the .then block that starts with
binary.getUrl(binary.version()).then(fileUrl => {
it also needs to be before the next reference to fileUrl.
For example:
binary.getUrl(binary.version()).then(fileUrl => {
binary.versionCustom = fileUrl.version;
fileUrl.url = fileUrl.url.replace(/_m1/, '');
let filePath = path.resolve(outputDir, binary.filename());
Note that this solution is temporary. It will be overwritten by an npm install. The Chromedriver and/or the webdriver-manager team will probably fix this issue, at which point you should clear the modified version of your webdriver-manager and download the fix from npm.
For macOS Catalina Version 10.15.6 (19G73)
In my case I was working with Rails and Capybara for feature tests. What worked for me was
First, find the actual chromedriver location running:
which chromedriver
# Which returned:
/Users/alex/.webdrivers/chromedriver
Then, install chromedriver via Homebrew:
brew install chromedriver
Then, remove old chromedriver reference found at previous location with:
rm /Users/alex/.webdrivers/chromedriver
Now, link the old chromedriver reference to the one installed with brew:
ln -s /usr/local/bin/chromedriver /Users/alex/.webdrivers/chromedriver
Then, open Finder app, then click on Go menu and then click Go to folder ... option, and enter this route:
/usr/local/Caskroom/chromedriver/
There you should see a folder with the chromedriver version you have installed, something like this:
88.0.4324.96
Enter that folder and you should see the chromedriver binary file.
Right click on it, and click on Open
Now, you should get a terminal window popping up with the output:
Last login: Sun Jan 31 12:29:15 on ttys001
/usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
  ~  /usr/local/Caskroom/chromedriver/88.0.4324.96/chromedriver ; exit;
Starting ChromeDriver 88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b- refs/branch-heads/4324#{#1784}) on port 9515
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
Finally, press Ctrl+C to stop the execution and quit the terminal window.
Now, you should be able to run capybara tests.
npm uninstall protractor && npm install protractor
If you use webdrivers gem, upgrade it:
bundle update webdrivers

Sublime Text 2 - BeautifyRuby don't work

i've installed BeautifyRuby in my Sublime Text 2 (running OS X Yosemite 10.10), but is not working, I receive this message when I try to cmd + ctrl + k:
Error: invalid output. Check your ruby interpreter settings
I've changed, as suggested https://github.com/CraigWilliams/BeautifyRuby , the sublime-settings file with:
"ruby": "/Users/alessiogastaldo/.rbenv/bin/ruby"
and also using the specific version:
"ruby": "/Users/alessiogastaldo/.rbenv/versions/1.8.7-p371/bin/ruby"
but with no success.
I've read the different solutions proposed (like https://github.com/CraigWilliams/BeautifyRuby/issues/52) but nothing works.
Anyone do know how to solve this?
I had the same problem too.
I solved with this:
In terminal, run the command: which ruby.
Copy the result. In my case was: "/home/user/.rbenv/shims/ruby"
Open your package settings. In my case: Preferences > Package Settings > BeautyfyRuby > Settings Default.
Add this line in the file: "ruby": "/home/user/.rbenv/shims/ruby",
You will need to install the htmlbeautifier gem.
Run the commmand in terminal: gem install htmlbeautifier
It works for me.

Webkit not found on OSX

I'm trying to compile mu that uses the headers webkit/webkitwebview.h and webkit/webkitwebresource.h. The OSX version of webkit framework located in /System/Library/Frameworks doesn't seem to have it, the headers are different and use NS data types and stuff.
So I downloaded webkit-gtk with MacPorts (since it's not available through Homebrew) and pointed $PKG_CONFIG_PATH to webkit-1.0.pc. I verified and this version has the needed headers.
But the problem is, I still get an error, the configure file doesn't seem to be able to find it.
checking for WEBKIT... no
I don't even know, actually, if webkit-1.0.pc is the package config it is looking for.
I had two other compilation problems prior to this, with glib.h and gtk.h but managed to go through. This is the last issue I need to resolve to have a fully functional email client in Emacs.
Help!
this worked for me [1]:
add this to ~/.profile (or wherever you take care of this stuff):
# ~/.profile stuff
export PKG_CONFIG_PATH="/opt/local/lib/pkgconfig/:$PKG_CONFIG_PATH"
then source:
$ source ~/.profile
then (assuming you're in the mu dir) voila [2]:
$ ./configure
[1] i have gtk installed via homebrew, installed webkit-gtk3 via macports, and cloned mu from the github repo. running os x 10.9.5
[2] here's the $ ./configure output:
mu configuration is complete.
------------------------------------------------
mu version : 0.9.10
Xapian version : 1.2.19
GLib version : 2.42.1
GMime version : 2.6.20
GTK+ version : 3.14.5
Webkit version : 2.4.7
Emacs version : GNU Emacs 24.4.51.1
Have wordexp : yes
Build mu4e emacs frontend : yes
Build 'mug' toy-ui (gtk+/webkit) : yes
McCabe's Cyclomatic Complexity tool : no
Have direntry->d_ino : yes
Have direntry->d_type : yes
------------------------------------------------

How can I use swift in Terminal?

I read What's new in Xcode 6. The article introduces some new feature about Xcode 6, and it says:
Command Line
Xcode’s debugger includes an interactive version of the Swift language, known as the REPL (Read-Eval-Print-Loop). Use Swift syntax to evaluate and interact with your running app or write new code in a script-like environment. The REPL is available from within LLDB in Xcode’s console, or from Terminal.
I want to know how to get the REPL?
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
then you can do one of these:
xcrun swift
lldb --repl
As of Xcode 6.1 - typing swift in the terminal launches the REPL as well.
Alternatively, if you don't want to mess up your current dev environment, you can just run:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift
Step 1: Open Terminal
Step 2: Type "swift"
Step 3: There's no step 3
Example:
GoldCoast:~ macmark$ swift
Welcome to Swift! Type :help for assistance.
1> println("Hello, world")
Hello, world
2> var myVariable = 42
myVariable: Int = 42
3> myVariable = 50
4> let myConstant = 42
myConstant: Int = 42
5> println(myVariable)
50
6> let label = "The width is "
label: String = "The width is "
7> let width = 94
width: Int = 94
8> let widthLabel = label + String(width)
widthLabel: String = "The width is 94"
9> :exit
GoldCoast:~ macmark$
In Xcode 6.1.1 with Command Line Tools installed you can execute scripts by referencing directly to /usr/bin/swift the following way:
#!/usr/bin/swift
let variable: String = "string"
print("Test \(variable)")
In the same fashion as running Swift from the Terminal, you can also execute scripts.
Just use the following shebang, and run your script. (As per Chris Lattner, creator of Swift)
#!/usr/bin/env xcrun swift -i
If any one cares a simple Swift script shebang:
#!/usr/bin/env xcrun --sdk macosx swift
If specific target version is required
#!/usr/bin/env xcrun --sdk macosx swift -target x86_64-macosx10.11
If specific toolchain is required (like you want to use Swift 2.3 but you are using Xcode 8)
#!/usr/bin/env xcrun --toolchain com.apple.dt.toolchain.Swift_2_3 --sdk macosx swift -target x86_64-macosx10.11
If you want to use Swift 2.2 in your Xcode 7.3.1, let's assume Xcode 7.3.1 is located at /Applications/Xcode7.app
sudo xcode-select -s /Applications/Xcode7.app/
xcrun --sdk macosx swift
from now on the default active developer directory changed, you can check that using:
xcode-select -p
If you want to use snapshots provided by Swift.org, you should not miss Installation here.
as first answered by me in Run swift script from Xcode iOS project as build phase
** update as of xcode6 beta 4 **
this can also be done on xcode preferences. simply go to xcode -> preferences -> locations.
for command line tools simply select the version you want from drop down list options, refer picture below. (swift requires path to be xcode6's path).
I will leave my previous answer below as well.
what Kaan said and you can also use an apple script to make simple application so you can use it to switch back and forth.
open apple script > paste this below code & export it as an application so with just one click you can switch to default path or beta path (to use swift)
set xcode6Path to "xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer"
set xcodeDefaultPath to "xcode-select -switch /Applications/Xcode.app/Contents/Developer"
display dialog "set xcode sdk path to " buttons {"xcode 6", "default"} default button 1
copy result as list to {buttonPressed}
if buttonPressed is "default" then
try
do shell script xcodeDefaultPath with administrator privileges
end try
else
try
do shell script xcode6Path with administrator privileges
end try
end if
then run > xcrun swift
disclaimer
the script assumes you have both xcode6-beta & xcode5 installed.
if you're a new developer who's trying out only xcode6beta you will not need any script or setting path manually. simply run xcrun swift as the path is already set for you.
when xcode6 is finally released you will need to reset your path back to default from this simple app and never use it again.
After installing the official Xcode 6.1 release, there is a swift command in /usr/bin/swift.
Bear in mind that if you have a Python different from the Apple-supplied Python in the path, swift can fail with ImportError: No module named site. In that case, make sure that you do export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin before calling swift.
The xcrun command will use the DEVELOPER_DIR environment variable to override the currently selected Xcode installation (as set with xcode-select). You can use that to construct a single command that'll run swift on the command line and put you in the REPL. That looks like this:
/usr/bin/env DEVELOPER_DIR=/Applications/Xcode6-Beta.app/Contents/Developer xcrun swift
and you can alias that to just 'swift':
alias swift="/usr/bin/env DEVELOPER_DIR=/Applications/Xcode6-Beta.app/Contents/Developer xcrun swift"
As an interesting side note, you can use the same kind of invocation to run a swift script just like you'd use bash or python by adding a -i:
#!/usr/bin/env DEVELOPER_DIR=/Applications/Xcode6-Beta.app/Contents/Developer xcrun swift -i
println("Hello World!")
Of course, once Xcode 6 is released officially and you switch to that as your default developer tools, you can drop the DEVELOPER_DIR=.. bits and just use "xcrun swift".
make sure you install xcode 6.0 ,but not 6.1
If you get an error:
<unknown>:0: error: the SDK 'MacOSX10.9.sdk' does not support Swift
just run
xcrun --sdk iphonesimulator8.0 swift
or you can
export SDKROOT="iphonesimulator8.0"
and then
xcrun swift
Use "xcodebuild -showsdks" to list the available SDK names.
if you install xcode 6.1,just
sudo xcode-select -s /Applications/*your-Xcode-6.1-path.app*/Contents/Developer
xcrun swift
For XCode6, run these commands:
$ sudo xcode-select -s /Applications/Xcode.app/Contents/Developer/
$ xcrun swift
If you get an error:
<unknown>:0: error: the SDK 'MacOSX10.9.sdk' does not support Swift
try:
xcrun swift -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk
open Terminal,
$sudo xcode-select -switch /Applications/Xcode6-Beta6.app/Contents/Developer
Notice: The Xcode6-Beta6.app should be replaced to appropriate version you installed
Then put this line alias swift='xcrun swift' to ~/.bash_profile
And,
$source ~/.bash_profile
$swift
There you go!
With the help of Swift REPL(Read Eval Print Loop).
Developers familiar with interpreted languages will feel comfortable in this command-line environment, and even experienced developers will find a few unique features
Launch Terminal.app and type swift and press enter. You’ll then be in the Swift REPL.
1> print("Hello Swift REPL")
Hello Swift REPL
2> 10 + 20
$R0: Int = 30
3> var name = "Yogendra Singh"
name: String = "Yogendra Singh"
4> print(name)
Yogendra Singh
5>

Ruby compile failed while installing on Mountain Lion 10.8?

This is the command I entered in the terminal while following "Ruby on Rails development with Mac OS X Mountain Lion", and its result:
rbenv install 2.0.0-p247
Downloading openssl-1.0.1e.tar.gz...
-> https://www.openssl.org/source/openssl-1.0.1e.tar.gz
Installing openssl-1.0.1e...
BUILD FAILED
Inspect or clean up the working tree at /var/folders/x8/19f_wwjx4gd26z6qdq874tj40000gs/T/ruby-build.20130919211135.42003
Results logged to /var/folders/x8/19f_wwjx4gd26z6qdq874tj40000gs/T/ruby- build.20130919211135.42003.log
Last 10 log lines:
RANLIB =true
ARFLAGS =
PERL =/usr/bin/perl
SIXTY_FOUR_BIT_LONG mode
DES_UNROLL used
DES_INT used
RC4 uses uchar
RC4_CHUNK is unsigned long
sh: make: command not found
/usr/local/bin/ruby-build: line 387: make: command not found
Please help!
/usr/local/bin/ruby-build: line 387: make: command not found means rbenv can't compile Ruby because the necessary tools aren't available.
Have you installed Xcode?
Have you installed its associated command-line applications? That's the second step needed, and is found inside the Xcode application.
Have you recently updated Xcode? If so, you might need to update the command-line tools too.

Resources