[MacRuby-devel] environment variables
Dear all,
Started playing with MacRuby again and I need to access the environment
variables.
Say I have a export VARIABLE_NAME = Whatever
I have tried both:
ENV['VARIABLE_NAME']
and
NSProcessInfo.processInfo.environment.objectForKey('VARIABLE_NAME')
Neither of which returns anything
Both works in macirb
Kind Regards,
Erik
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
Re: [MacRuby-devel] environment variables
Hi Erik,
Are you trying to access the environment variables from inside an app or just
another script?
Can you also tell me what version of MacRuby you are using?
Thanks,
Mark
On 2012-10-17, at 11:39 AM, Erik Lundqvist
wrote:
> Dear all,
>
> Started playing with MacRuby again and I need to access the environment
> variables.
>
> Say I have a export VARIABLE_NAME = Whatever
>
> I have tried both:
> ENV['VARIABLE_NAME']
> and
> NSProcessInfo.processInfo.environment.objectForKey('VARIABLE_NAME')
>
> Neither of which returns anything
>
> Both works in macirb
>
> Kind Regards,
> Erik
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
Re: [MacRuby-devel] environment variables
Hi Mark,
It's a MacRuby 0.12 app.
Thank you
On 17 Oct 2012, at 20:56, Mark Rada wrote:
> Hi Erik,
>
> Are you trying to access the environment variables from inside an app or just
> another script?
> Can you also tell me what version of MacRuby you are using?
>
> Thanks,
> Mark
>
>
> On 2012-10-17, at 11:39 AM, Erik Lundqvist
> wrote:
>
>> Dear all,
>>
>> Started playing with MacRuby again and I need to access the environment
>> variables.
>>
>> Say I have a export VARIABLE_NAME = Whatever
>>
>> I have tried both:
>> ENV['VARIABLE_NAME']
>> and
>> NSProcessInfo.processInfo.environment.objectForKey('VARIABLE_NAME')
>>
>> Neither of which returns anything
>>
>> Both works in macirb
>>
>> Kind Regards,
>> Erik
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
Re: [MacRuby-devel] environment variables
Ok, so it looks like you are setting the environment variable from the
Terminal.app, and then running the app from Xcode or launching from Finder.
If that's the case, then what you export from the Terminal would not be
available to apps. Exported variables will only be available to descendant
processes. The parent process of your app is a launchd process for your user;
and that launchd process has a parent of the root launchd process (and it
doesn't have a parent). You can see the hierarchy when you run Activity Monitor
and use the "All Processes, Hierarchically" filter.
A shell session in Terminal will be a child of Terminal; and if you run a
program from that shell it will be a child of the shell, which is why you can
see the exported variable from macirb.
If you are using Xcode, try editing the Scheme for running the app. The "Run"
stage should have a list of environment variables that can be set and you can
add your variables there instead.
HTH,
Mark
On 2012-10-17, at 11:39 AM, Erik Lundqvist
wrote:
> Dear all,
>
> Started playing with MacRuby again and I need to access the environment
> variables.
>
> Say I have a export VARIABLE_NAME = Whatever
>
> I have tried both:
> ENV['VARIABLE_NAME']
> and
> NSProcessInfo.processInfo.environment.objectForKey('VARIABLE_NAME')
>
> Neither of which returns anything
>
> Both works in macirb
>
> Kind Regards,
> Erik
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
Re: [MacRuby-devel] environment variables
OK thanks for explaining it Mark.
I'm afraid setting the variable again in Xcode is not an option. I was hoping
to pick up $CATALINA_HOME to find out where a user had installed tomcat.
On 17 Oct 2012, at 21:51, Mark Rada wrote:
> Ok, so it looks like you are setting the environment variable from the
> Terminal.app, and then running the app from Xcode or launching from Finder.
>
> If that's the case, then what you export from the Terminal would not be
> available to apps. Exported variables will only be available to descendant
> processes. The parent process of your app is a launchd process for your user;
> and that launchd process has a parent of the root launchd process (and it
> doesn't have a parent). You can see the hierarchy when you run Activity
> Monitor and use the "All Processes, Hierarchically" filter.
>
> A shell session in Terminal will be a child of Terminal; and if you run a
> program from that shell it will be a child of the shell, which is why you can
> see the exported variable from macirb.
>
> If you are using Xcode, try editing the Scheme for running the app. The "Run"
> stage should have a list of environment variables that can be set and you can
> add your variables there instead.
>
> HTH,
> Mark
>
> On 2012-10-17, at 11:39 AM, Erik Lundqvist
> wrote:
>
>> Dear all,
>>
>> Started playing with MacRuby again and I need to access the environment
>> variables.
>>
>> Say I have a export VARIABLE_NAME = Whatever
>>
>> I have tried both:
>> ENV['VARIABLE_NAME']
>> and
>> NSProcessInfo.processInfo.environment.objectForKey('VARIABLE_NAME')
>>
>> Neither of which returns anything
>>
>> Both works in macirb
>>
>> Kind Regards,
>> Erik
>> ___
>> MacRuby-devel mailing list
>> [email protected]
>> http://lists.macosforge.org/mailman/listinfo/macruby-devel
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
[MacRuby-devel] Quartz 2D Graphics problem
Hi,
I went back to working on an old project that uses core graphics and I'm having
problems getting it to run again.
The following code gives me an error with the graphics context:
def drawRect( rect )
return unless @controller
begin
@context = NSGraphicsContext.currentContext.graphicsPort
# Scale 15 min intervals to chart area
@xscale = bounds.size.width / 25.0
height = bounds.size.height
@yscale = height / 2.0
CGContextScaleCTM( @context, @xscale, @yscale )
CGContextTranslateCTM( @context, 0.5, 0.5 ) # Indent
from bounds
# restore text size
CGContextSetTextMatrix( @context,
CGAffineTransformMakeScale( 1 / @xscale, 1 / @yscale ))
show_index( height )
rescue => e
ErrorLog.instance.rescue_error( e )
end
end
unrecognized runtime type `{CGContext=}'
/Users/robertrice/Library/Developer/Xcode/DerivedData/MacDriverLog-ebberjlfoqoqdzenjgqkdbkehuoj/Build/Products/Debug/MacDriverLog.app/Contents/Main_Window.bundle/Contents/Resources/RemarksIndexView.rb:55:in
`drawRect'
/Users/robertrice/Library/Developer/Xcode/DerivedData/MacDriverLog-ebberjlfoqoqdzenjgqkdbkehuoj/Build/Products/Debug/MacDriverLog.app/Contents/Resources/rb_main.rb:69:in
`'
line 55 is the first line:
@context = NSGraphicsContext.currentContext.graphicsPort
Has anything changed with regard to Quartz 2D drawing?
Thanks,
Bob Rice
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
Re: [MacRuby-devel] Quartz 2D Graphics problem
It seems as though the BridgeSupport definition of CGContextRef is missing. At
this point, I'm not sure where it should be coming from, documentation
indicates ApplicationServices.framework, but it's not in there.
On Mountain Lion, we have a similar problem with some CoreGraphics definitions
missing from the bridge support file it should be in. In that case, it turned
out that Apple has two CoreGraphics.frameworks and only one shows up in the
dependency chain. I did a quick ack through the /System/Library/Frameworks and
didn't see a definition for CGContextRef, so I'm not sure if I missed it or if
it is somewhere else now.
Bridge support on stuff that is changing seems to be a bit iffy on Mountain
Lion. The bridge support source used to be on macosforge.org, but Apple seems
to have taken it down (the bridge support developer left Apple and moved to
Belgium). The long term strategy will be to bring the bridge support stuff into
MacRuby itself; however, someone who has the source code will have to post it
somewhere for us first.
Sorry that I don't have better news; Objective-C for this segment might be your
only option. :(
--
Mark
On 2012-10-18, at 12:30 AM, Robert Carl Rice wrote:
> Hi,
>
> I went back to working on an old project that uses core graphics and I'm
> having problems getting it to run again.
>
> The following code gives me an error with the graphics context:
>
> def drawRect( rect )
> return unless @controller
>
> begin
> @context = NSGraphicsContext.currentContext.graphicsPort
>
> # Scale 15 min intervals to chart area
> @xscale = bounds.size.width / 25.0
> height = bounds.size.height
> @yscale = height / 2.0
> CGContextScaleCTM( @context, @xscale, @yscale )
> CGContextTranslateCTM( @context, 0.5, 0.5 ) # Indent
> from bounds
>
> # restore text size
> CGContextSetTextMatrix( @context,
> CGAffineTransformMakeScale( 1 / @xscale, 1 / @yscale ))
> show_index( height )
>
> rescue => e
> ErrorLog.instance.rescue_error( e )
> end
> end
>
> unrecognized runtime type `{CGContext=}'
> /Users/robertrice/Library/Developer/Xcode/DerivedData/MacDriverLog-ebberjlfoqoqdzenjgqkdbkehuoj/Build/Products/Debug/MacDriverLog.app/Contents/Main_Window.bundle/Contents/Resources/RemarksIndexView.rb:55:in
> `drawRect'
> /Users/robertrice/Library/Developer/Xcode/DerivedData/MacDriverLog-ebberjlfoqoqdzenjgqkdbkehuoj/Build/Products/Debug/MacDriverLog.app/Contents/Resources/rb_main.rb:69:in
> `'
>
> line 55 is the first line:
> @context = NSGraphicsContext.currentContext.graphicsPort
>
> Has anything changed with regard to Quartz 2D drawing?
>
> Thanks,
> Bob Rice
>
> ___
> MacRuby-devel mailing list
> [email protected]
> http://lists.macosforge.org/mailman/listinfo/macruby-devel
___
MacRuby-devel mailing list
[email protected]
http://lists.macosforge.org/mailman/listinfo/macruby-devel
