Error "Cannot Install Extension"

Hi Nick,

I tried to install the ‘/em’ extension from Hans van Maanen: Diversen: PopClip Extensions
but I get the following error:

Cannot Install Extension
Executable script ‘Doe.rb’ requires shebang (!#)

Could you please look into it?
An extension that adds the Latex formatting would help me a lot.

The trouble is that the extensions on that page are built for an older version of PopClip that was more lenient about how it loaded shell scripts.

The Ruby script in the extension is marked executable but does not have the required line at the top to indicate how it should run.

The page author might be willing to update them if they are still interested in maintaing them. Possible fixes:

  1. Remove the executable bit from the ruby file
  2. Add #!/usr/bin/ruby to the top of the file

If you just want to try that one extension quickly, I’ve reformatted the “\em” as the following snippet which you can just select all of to install on latest PopClip:

#!/usr/bin/ruby
# #popclip
# name: \em
# identifier: org.vanmaanen.extension.texem
# description: LaTeX formatting
# requirements: [text, paste]
# after: paste-result

a = ENV['POPCLIP_TEXT']
k = ENV['POPCLIP_MODIFIER_FLAGS'].to_i

case k
when 0
	b = "\\emph{" + a + "}"
when 524288
	b = "\\textit{" + a + "}"
when 1048576
	b = "\\textbf{" + a + "}"
when 1572864
	b = "\\textbf{\\textit{" + a + "}}"
when 262144, 786432,1310720
	if a[0..0] == "\\"
	b = a.slice(a.index("{")+1..-2)
	else
	b = a
	end
else
	b = "{" + a + "}"
end
print b

(The above block is an extension snippet — select it then click “Install Extension” in PopClip.)

Thanks a lot, your snippet works perfectly!

I will inform the author, but I don’t think he’s updating the extensions anymore, the last change seems to have been in 2014.

1 Like