I've just dowloaded entrez direct on my Mac and I was trying to perform some simple queries like:

esearch -db pubmed -query "tn3 transposition immunity" | efetch -format medline

but I keep getting this error

curl: (22) The requested URL returned error: 400 Bad Request
 ERROR:  curl command failed ( Mar 19 Ott 2021 13:02:26 CEST ) with: 22 
https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi -d db=pubmed&id=Unable%2Cto%2Clocate%2Cxtract%2Cexecutable.%2CPlease%2Cexecute%2Cthe%2Cfollowing%2Cnquire%2Cdwn%2Cftp.ncbi.nlm.nih.gov%2Centrez%2Centrezdirect%2Cxtract.Darwin.gz%2Cgunzip%2Cf%2Cxtract.Darwin.gz%2Cchmod%2Cx%2Cxtract.Darwin&rettype=medline&retmode=text&tool=edirect&edirect=16.1&edirect_os=Darwin&email=mariocatalano%40MBP-di-Mario.lan"

I'm using bash scripts on my Mac's terminal

How should I fix this?

  • $\begingroup$ update your curl or esearch version, use the miniconda/brew versions. If you already have conda, you can create an environment and install it on it. $\endgroup$
    – zorbax
    Commented Oct 19, 2021 at 11:57
  • 2
    $\begingroup$ Looks like you haven't installed it correctly. The error is saying it cannot locate/extract the executable. $\endgroup$
    – terdon
    Commented Oct 19, 2021 at 12:31
  • $\begingroup$ @zorbax -- it is recommended to use the official version of Edirect instead of the ones from miniconda, brew, etc as they often tend to be quite behind the latest, official version. $\endgroup$
    – vkkodali
    Commented Oct 20, 2021 at 16:55

1 Answer 1


It's not a curl problem. (The 22 error is just passing along the server-side HTTP 400 error, which is because it dumped an error message into a URL.) I think terdon is right and there's something wrong with your edirect installation. You have esearch and efetch on your PATH but apparently not xtract and/or xtract.Darwin.

More detail:

Look toward the end of the error message, at the text being passed to curl's -d argument:


It's putting this in the id= part:


which is maybe something like (trying to guess which characters got turned into %2C):

Unable to locate xtract executable. Please execute the following: nquire -dwn ftp.ncbi.nlm.nih.gov entrez/entrezdirect xtract.Darwin.gz; gunzip -f xtract.Darwin.gz; chmod +x xtract.Darwin

But you should already have xtract and xtract.Darwin from the same edirect install that gave you esearch and efetch.

For what it's worth the official Entrez Direct install on Mac OS looks a little goofy. When I try it myself it ends with:

Entrez Direct has been successfully downloaded and installed.

-e In order to complete the configuration process, please execute the following:

  echo "export PATH=\\\${PATH}:" >> $HOME/.bashrc
  echo "export PATH=\\\${PATH}:" >> $HOME/.zshrc

or manually edit the PATH variable assignments in your .bashrc and .zshrc files.

Would you like to do that automatically now? [y/N]

Those commands don't look right (what's getting added to the path? an empty string?) and if I say y, I get this at the end of .bashrc and .zshrc which definitely isn't right:

export PATH=${PATH}:

It seems like an empty string at the end of PATH behaves like . (current directory), so I can go into ~/edirect and run your command and it does actually work. So this isn't exactly your problem... but still, that seems wrong.

  • 1
    $\begingroup$ Note that macOS uses login shells by default for historical reasons, which means that if the OP is using bash (which is no longer the default on macOS), then ~/.bashrc is irrelevant and they should use ~/.profile instead. Either way though, that command is quite wrong, as you point out. $\endgroup$
    – terdon
    Commented Oct 20, 2021 at 9:19
  • $\begingroup$ This was an issue with the Edirect installation script. The install-edirect.sh script has been updated to fix this issue. Please follow the instructions here to install. $\endgroup$
    – vkkodali
    Commented Oct 20, 2021 at 16:52
  • $\begingroup$ Thanks! The install still seems to misbehave on Mac OS, though. When I say ymy ~/.bashrc is now untouched and my ~/.zshrc contains literallyexport PATH=${PATH}:/Users/jesse echo export PATH=${PATH}:/Users/jesse $\endgroup$
    – Jesse
    Commented Oct 20, 2021 at 17:51
  • $\begingroup$ @Jesse thank you for trying it out. This is yet another issue that needed a quick fix. The updated script is already on FTP so if you try again it should work. Sorry for the inconvenience. $\endgroup$
    – vkkodali
    Commented Oct 20, 2021 at 20:11
  • $\begingroup$ No trouble, thanks for working on this. Still behaving strangely for me but when I look at the script I think I see one reason. It references DIR when setting up PATH, but that's the original working directory / the directory containing the install script, not the destination directory, right? Should that instead be a $PWD or something once inside the ~/edirect location, maybe? We might be drifting from OP's question but I'm happy to help debug this via email or a github gist or something. $\endgroup$
    – Jesse
    Commented Oct 21, 2021 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.