 So It started let's say so my name is Bjorn. I'm a developer Yeah, I'm a developer my name is by ready country of people which why was a little barrier on the other side So let's get started. What's an environment variable? An environment variable is something that belongs to each When you run a process on a unique system You have a little bit of a sandbox simplified which where you can store a little bit of information about what is currently running Some of this information is environment variables and they can control what you can see and they can control various aspects of your program You have something that can set which time zone you're in except language you have much different information if you're running on a roll call you have seen in different places and how we consume stuff and One key thing where it comes to my variables is how do you set them? See so this easy way except my name I Want to output my name comes out in terminal already now on my bash prompt or CSH or whatever but The interesting part is but doing that. I'm not making it available anywhere It is just an environment variable, but it's not available for anyone else Which is the magic thing with export which makes us of any program that you execute from the current shell with Inherit all the variables available to you Which gets really important when you're looking with your very working with your variables in other places Which we're coming to you like starting off See pop quiz Anyone can guess what this does so we take my AWS access key Which is fake and I create the ice cream bucket for it up Which you know, it's an environment variable. Let's say it's on a computer. Nothing could be could be wrong with this Just continue on Anything in your environment variable is available to anyone on your computer Which might be fine, but Probably not so if you're in a shared environment, which you are in many hosting environments Everything you have available is visible everywhere So if I run through the sample here, you can see that if I just do a ps I can see everything every single environment very well said So you can see here that I have a skill install and a bunch of other weird stuff in my environment just from checking Sleep does nothing it just waits Why would you know and another thing with environment variables? There's a bunch of them that you get by default. So you have your Bash variable. You have your own variable. You have your shell variable Plan, etc. They're all being set by a very much places in your system with something. It's called a login shell by default So when you start your environment in your shell It will load It will load everything from this place And You have set here. This is a custom shell script that you can run whenever you start a new shell That is running along as a login shell Along in shell is a special thing that runs whenever you start in your terminal So anything that you run as a shell script will by default not load them And it will also load your bash rc, cshrc, and so on. I'm sorry if my speakers know it's your messed up and I'm losing track If anyone has any questions because I feel that was slightly confusing because I got lost please please raise hands ask So all of this why is important? Well, so your environment variable sets a lot of stuff where in your when you're running And one of the best examples of how everything works is rbm, pyam, the like, rbm as well Because the way it works is that it mucks about with your path your path is a Place where you have access to all your programs that you're developed to apps that you can use And whenever you try to launch something it will look through Your environment environment one by one and see that there exists a program here that is named what I expected so for instance if I wanted to find Ruby and We can see here in my environment that there is Ruby somewhere so we'll start at first off big Because it knows them We'll then check user bin and Then it goes to user local then you find okay. There's a revision there But the problem here was that I wanted it to find The rbn Ruby which is defined. I have Ruby version 2.3 I don't have version 2.0, which is come by default with my old allergic OS X Which is an issue because then I have to move things around to get it to the right version I want so that is a usual problem that you often find if you start out and you have no idea about this that You start to change the orders that comes first left or right This comes all into the bugging Because I've noticed over the last year that I've been spending a lot of time dealing with environment variables and production settings because Problem is it doesn't always get set. Oh, it does get set It doesn't get set, but who do you think you're sending it? So It gets all messed up. So for instance in its grips You're not running your script is logging shells. You have no idea what rbn where rbn is So you're running your thing you're testing it out. You're only in your terminal. You're running your script It's all working. You start running from crontab. It's not working anymore. What's up with that? Oh That top time on that shell at the end of bachelor you'll probably probably start working Some programs don't hear the environment at all because they see came that's insecure and next is a good example of this And I have a story about how I had an issue with engine eggs that took me hours to figure out why it wasn't fighting Ruby There's also lots of the main way of solving this is either by start finding lots of backward scripts Well, that's basically the only way to solve this in a sense of the way So you end up having something that calls your script in the end Which works out, but it's an only so example of this is at work. We were using Ruby version 2.0.0 with wk html and With passenger we're trying to mimic a production environments. We're running engine x locally Everything was working until we upgrade to 2.1.3 So when we did that all of a sudden wk html was saying no, I'm running 2.0.0 like I always have So why would it do that? It doesn't make any sense. I've told it that you're running 2.2.3 but 2.1.3 But the problem was that engine x wasn't setting path at all So I had to set it to use not use machines Then I did use it and it worked through but Wk html was running everything through the environment and It was picking up and finding that oh, yeah There's a Ruby version file in my home directory and all of a sudden you're running 2.0.0 anyways and all of this is messed up because Who would think of finding something like this? So yeah This is the fun stuff doing that guys So the fun part here is how the rbm shoes work. Does anyone here actually know how rbm works? So rbm shoes are kind of cool because the way they works is that they install a binary in your path like a small shell script So when you want to Ruby it will check okay, what are my current Ruby versions that are installed? I will then check do I have a Ruby version file that I can use and then it will replace the current version of what you have with that Ruby version But if you get started in the wrong location, it might go off and take something completely different which is what happened like this and It doesn't even matter when you get yourself set if it gets completely off Another interesting thing that happened. We were running a Python script that was running For some reason it was telling me it was 1968. It was running ASCII encoding and it was blowing up because the Chinese name Which doesn't make sense. It was in a boot-to-box. It is today. It's like 2016. It knows how to deal with the UTF-8 Our sysad was telling us everything is fine. I'm logging into the server. Look at my output for my prompt Look at me typing END. I can see all my things and it's saying NES UTF-8 but Python was running inside of something called SupervisorD that removes everything in the environment Nothing was there and by default it uses POSIX Which knows A to C Completely pointless. So we set our environment variable and we checked it out and we can see what was at that Another small case of something you can find I love RubyMind. I'm sure people will not probably have to hear that because you know We all have to grow up. Stop using bin-man stuff Yay! I know this so much I've been arguing for e-max support, but apparently that's also not Nice. Shouldn't be this way So we're running RubyMind. We're trying to run our test suite. We're running our spank And it keeps telling me Ruby doesn't have a Ruby Also, I can see that it's pointing to my shim folder. We talked about how shims work So I looked in my shims folder and it's like, oh no, there's actually no Ruby here And then I checked that my path to path, where is my shim folder? And it points to the one that is installed by home folder So remove .rbm in the home folder and all of a sudden RubyMind is actually working Because it's all about the path Pulling it together Check your path It's one of these tiny little things but it keeps coming up I was also building a one-point passenger and trying to get it to work together with Apache And the same thing, it didn't know where Apache was in home boot It just keeps popping up And the easiest way to check it is just to do an ENV And it will tell you print out every single environment variable in the current shell Or in the current place where you're running It's super useful for debugging There are a bunch of environment variables that change drastically the way your program behaves TC for instance, that's the time zone If you have a server that's configured to run in London or UTC as it's called And you need to output a timestamp that is in Singapore time You can set TC to be either GMT plus 8 or asia slash Singapore And it will know how to output it to make money here This is one of the few reasons I ended up writing a pro script without salarizing my scripts Because there's only one who listened to it And your basic unit skills pays off So learn some new use, it's all good So, please And I'm sorry, I feel that I was very confusing and bad today I got really distracted with my notes off So, here's a happy dog in his head So, here's a happy dog in his head Because you're still a captive audience, you get to hear about some Ruby jokes I made So, I've been working at... Ah, that's it There we are, we had a big-ish Rails problem over the last year We've had some really weird requirements sometimes So, one of the weird things we have is that our app is split to you It has a public place inside Which is all HTTPS everywhere, always Then we have an internal side That cannot be HTTPS everywhere, no, never Because then you can't inspect the traffic Because security So, a gem to remove and add the secure flag on cookies Very niche use case, but if you have it It's available Another fairly niche use case is the Note Rails Rape Runner So, this is that we're having a really large test One that takes two hours to run And we started out, it was really small And it ran really fast And we were using Rape Task to get our cucumber stuff set up After nine months running a single Rape Task It took something like 11 to 12 seconds, most of it moved up time Which, not very good So this thing, you put it in, it's a Rails engine It sits in your app And you hit it with a get request And we'll give back whatever Rape Task is It usually takes a second So, if you have special needs, that might be good So, thank you Not so much of a question, but anyway Have you used the command which To figure out what executable is actually running Yes, I have So, most of the time, the issue is that You have to figure out where you are right now And that's the main issue Because which tells you where you are in your current shell So, most of the time when I've been in this position Running which, in the context of where I was running It was engine X or anywhere else It was mostly confusing It was usually easier to just print out my path Or my environment, totally And then, more questions can be asked So, thank you